Evaluate solution from Laplace - matlab

The following variables were the solutions of a system of ODE by means of Laplace transform. The question is, how can I evaluate this as a function of t?
zs =
(426453367703541750000*sin(t))/422998807223231216101 - (126885219268500000*cos(t))/422998807223231216101 - (143127622539985885236418500000*sum(exp(r3*t)/(2*(169386*r3^3 + 3312090*r3^2 + 336237395*r3 + 891000000)), r3 in RootOf(s3^4 + (736020*s3^3)/28231 + (336237395*s3^2)/84693 + (594000000*s3)/28231 + 13810500000/28231, s3)))/422998807223231216101 - (898981813790513658018000000*sum((r3*exp(r3*t))/(2*(169386*r3^3 + 3312090*r3^2 + 336237395*r3 + 891000000)), r3 in RootOf(s3^4 + (736020*s3^3)/28231 + (336237395*s3^2)/84693 + (594000000*s3)/28231 + 13810500000/28231, s3)))/422998807223231216101 - (35837444893658057322750000*sum((r3^2*exp(r3*t))/(2*(169386*r3^3 + 3312090*r3^2 + 336237395*r3 + 891000000)), r3 in RootOf(s3^4 + (736020*s3^3)/28231 + (336237395*s3^2)/84693 + (594000000*s3)/28231 + 13810500000/28231, s3)))/422998807223231216101 + (10746289875507070500000*sum((r3^3*exp(r3*t))/(2*(169386*r3^3 + 3312090*r3^2 + 336237395*r3 + 891000000)), r3 in RootOf(s3^4 + (736020*s3^3)/28231 + (336237395*s3^2)/84693 + (594000000*s3)/28231 + 13810500000/28231, s3)))/422998807223231216101
zu =
(423526351592241700000*sin(t))/422998807223231216101 - (119538342000000*cos(t))/422998807223231216101 - (21856954524657863661418500000*sum(exp(r3*t)/(2*(169386*r3^3 + 3312090*r3^2 + 336237395*r3 + 891000000)), r3 in RootOf(s3^4 + (736020*s3^3)/28231 + (336237395*s3^2)/84693 + (594000000*s3)/28231 + 13810500000/28231, s3)))/422998807223231216101 - (935131412760109308018000000*sum((r3*exp(r3*t))/(2*(169386*r3^3 + 3312090*r3^2 + 336237395*r3 + 891000000)), r3 in RootOf(s3^4 + (736020*s3^3)/28231 + (336237395*s3^2)/84693 + (594000000*s3)/28231 + 13810500000/28231, s3)))/422998807223231216101 - (35869453347570289778100000*sum((r3^2*exp(r3*t))/(2*(169386*r3^3 + 3312090*r3^2 + 336237395*r3 + 891000000)), r3 in RootOf(s3^4 + (736020*s3^3)/28231 + (336237395*s3^2)/84693 + (594000000*s3)/28231 + 13810500000/28231, s3)))/422998807223231216101 + (10124060799006000000*sum((r3^3*exp(r3*t))/(2*(169386*r3^3 + 3312090*r3^2 + 336237395*r3 + 891000000)), r3 in RootOf(s3^4 + (736020*s3^3)/28231 + (336237395*s3^2)/84693 + (594000000*s3)/28231 + 13810500000/28231, s3)))/422998807223231216101

Are these built with the Symbolic Math Toolbox?
Try
t=0:0.01:10;
values_s = zs(t);
values_u = zu(t);

Related

MATLAB: When specifying the color of points, legend does not match

I am using MATLAB R2017b.
This section of the code is generating the data to be plotted:
% Parameters
cE = 0.1;
cs = 0.1;
a0 = 0.5;
a = 0.5;
L= 0.1;
b=1
% Parameter in inspection
eStart=0.0; %inicial value of parameter
eStep=0.01; %how far apart is each value
eEnd=1; %Final value of parameter
e = eStart:eStep:eEnd; %Array containing all parameters
nPoints = length(e); %number of parameter values used
T=700; % time interval
transientCut = 500; %indicates the cut to avoid seeing transient
% points (points before reach equilibtium);
%thus as transientCut increases the graph will start to
%show points that did not reach equilibrium yet
%setting the matrix that will save the time series for each value of parameter used
XIR=zeros(nPoints,T);
XiR=zeros(nPoints,T);
XIr=zeros(nPoints,T);
Xir=zeros(nPoints,T);
for k=1:nPoints %outer loop gives the condition in which the eValues
% will be accesed
xiR =0.5 %IC
xIr =0.20 %IC
xir = 0.3 %IC
xIR= 1-xiR-xIr-xir;
for t=1:T
%Difference equation
xIR=(xIR*(1 + (a0 + a*(L*xIr + xIR))*(-cE - cs + (1 - xir - xIr + (xir + xIr)*e(k))^b)))/(xiR + xIr + xIR - cE*xiR*(a0 + a*(L*xIr + xIR)) - (cE + cs)*(a0*(xIr + xIR) + a*xIR*(L*xIr + xIR)) + xir*(1 - a0*cE + (a0 + a*(L*xIr + xIR))*((-1 + xir + xIr)*(-1 + e(k)))^b) + xIr*(a0 + a*(L*xIr + xIR))*((-1 + xir + xIr)*(-1 + e(k)))^b + a0*(xir + xIr)*e(k)^b + (xiR + xIR)*(a0 + a*(L*xIr + xIR))*(1 - xir - xIr + (xir + xIr)*e(k))^b);
xiR=(xiR + xiR*(a0 + a*(L*xIr + xIR))*(-cE + (1 - xir - xIr + (xir + xIr)*e(k))^b))/(xiR + xIr + xIR - cE*xiR*(a0 + a*(L*xIr + xIR)) - (cE + cs)*(a0*(xIr + xIR) + a*xIR*(L*xIr + xIR)) + xir*(1 - a0*cE + (a0 + a*(L*xIr + xIR))*((-1 + xir + xIr)*(-1 + e(k)))^b) + xIr*(a0 + a*(L*xIr + xIR))*((-1 + xir + xIr)*(-1 + e(k)))^b + a0*(xir + xIr)*e(k)^b + (xiR + xIR)*(a0 + a*(L*xIr + xIR))*(1 - xir - xIr + (xir + xIr)*e(k))^b);
xIr=(xIr*(1 - a0*(cE + cs) + (a0 + a*(L*xIr + xIR))*((-1 + xir + xIr)*(-1 + e(k)))^b + a0*e(k)^b))/(xiR + xIr + xIR - cE*xiR*(a0 + a*(L*xIr + xIR)) - (cE + cs)*(a0*(xIr + xIR) + a*xIR*(L*xIr + xIR)) + xir*(1 - a0*cE + (a0 + a*(L*xIr + xIR))*((-1 + xir + xIr)*(-1 + e(k)))^b) + xIr*(a0 + a*(L*xIr + xIR))*((-1 + xir + xIr)*(-1 + e(k)))^b + a0*(xir + xIr)*e(k)^b + (xiR + xIR)*(a0 + a*(L*xIr + xIR))*(1 - xir - xIr + (xir + xIr)*e(k))^b);
xir=(xir*(1 - a0*cE + (a0 + a*(L*xIr + xIR))*((-1 + xir + xIr)*(-1 + e(k)))^b + a0*e(k)^b))/(xiR + xIr + xIR - cE*xiR*(a0 + a*(L*xIr + xIR)) - (cE + cs)*(a0*(xIr + xIR) + a*xIR*(L*xIr + xIR)) + xir*(1 - a0*cE + (a0 + a*(L*xIr + xIR))*((-1 + xir + xIr)*(-1 + e(k)))^b) + xIr*(a0 + a*(L*xIr + xIR))*((-1 + xir + xIr)*(-1 + e(k)))^b + a0*(xir + xIr)*e(k)^b + (xiR + xIR)*(a0 + a*(L*xIr + xIR))*(1 - xir - xIr + (xir + xIr)*e(k))^b);
%saving for each value of e (at row k), the time serie
XIR(k,t)=xIR;
XiR(k,t)=xiR;
XIr(k,t)=xIr;
Xir(k,t)=xir;
end
end
Here is where the problem is.
If I let the MATLAB default choose the colors the legend matches the color.
But if I specify the shape and color of the data, then legend does not match these specifications (see attached below)
figure
plot(eStart:eStep:eEnd, XIR(:,transientCut:T),'g*' ,eStart:eStep:eEnd, XiR(:,transientCut:T),'b.' ...
,eStart:eStep:eEnd, XIr(:,transientCut:T),'r.' ,eStart:eStep:eEnd, Xir(:,transientCut:T),'k.')
xlabel('xlable','FontSize',12)
ylabel('ylable','FontSize',12)
ylim([0 1])
title(['c_{s}=',num2str(cs),', c_{E}=',num2str(cE),...
', L=',num2str(L),', a_{0}=',num2str(a0), ', a=',num2str(a)])
legend('XIR','XiR','XIr','Xir')
Notice the legend does not match the color and shape in the graph
I also tried suggestions of similar issues that I found in this forum, but the legend still does not match the color/shape specifications:
p1=plot(eStart:eStep:eEnd, XIR(:,transientCut:T),'g*');
hold on
p2=plot(eStart:eStep:eEnd, XiR(:,transientCut:T),'b.');
p3=plot(eStart:eStep:eEnd, Xir(:,transientCut:T),'r.');
p4=plot(eStart:eStep:eEnd, Xir(:,transientCut:T),'k.');
xlabel('xlable','FontSize',12)
ylabel('ylable','FontSize',12)
ylim([0 1])
title(['c_{s}=',num2str(cs),', c_{E}=',num2str(cE),...
', L=',num2str(L),', a_{0}=',num2str(a0), ', a=',num2str(a)])
legend([p1;p2;p3;p4], {'xIR','xiR','xIr','xir'})
ylabel('ylable','FontSize',12)
ylim([0 1])
title(['c_{s}=',num2str(cs),', c_{E}=',num2str(cE),...
', L=',num2str(L),', a_{0}=',num2str(a0), ', a=',num2str(a)])
legend('XIR','XiR','XIr','Xir')
The problem is the shape of your data. Your data for the y-axis, XIR, Xir, ... are all matrices.
So when you use the command: plot(eStart:eStep:eEnd, XIR(:,transientCut:T),'g*'), you are getting more than just one data series.
Try this out and you will see what I mean:
plot(eStart:eStep:eEnd, XIR(:,transientCut:T),'g*')
legend
Where you were supposedly trying to plot one data series XIR, there will be 201 series instead. (size of eStart:eStep:eEnd is a [1,101] vector, while size of XIR(:,transientCut:T) is a [101,201] matrix).
To fix this, you have two options.
Sort out how you want to plot your data. So convert the datasets like XIR(:,transientCut:T) into a vector when plotting.
If you really need to plot it with that code you have, you can "trick" matlab, by plotting an empty dataset with the same markers before your dataset.
figure
hold on
plot(NaN, NaN, 'g*') % Same marker style as XIR
plot(NaN, NaN, 'b.') % Same marker style as XiR
plot(NaN, NaN, 'r.') % Same marker style as XIr
plot(NaN, NaN, 'k.') % Same marker style as Xir
% Plot your data as normal
plot(eStart:eStep:eEnd, XIR(:,transientCut:T),'g*' ,eStart:eStep:eEnd, XiR(:,transientCut:T),'b.' ...
,eStart:eStep:eEnd, XIr(:,transientCut:T),'r.' ,eStart:eStep:eEnd, Xir(:,transientCut:T),'k.')
% Call legend after plotting your data
legend('XIR','XiR','XIr','Xir')
P.S. I recommend that you rename your variables too. XIR, XiR, XIr, Xir are all too easy to switch up, as can be seen in your last code snippet:
p1=plot(eStart:eStep:eEnd, XIR(:,transientCut:T),'g*');
hold on
p2=plot(eStart:eStep:eEnd, XiR(:,transientCut:T),'b.');
p3=plot(eStart:eStep:eEnd, Xir(:,transientCut:T),'r.'); <-- XIr, not Xir?
p4=plot(eStart:eStep:eEnd, Xir(:,transientCut:T),'k.');

Matlab "solve" doesn't give the two roots to equation

I'm trying to solve the Machnumber-Area equation for isentropic flows. This equation has two real positive roots, but I'm not able to get any of these when trying to solve with the "solve" routine.
The code to solve the equation:
gamma = 1.4;
L = 3;
n = 30;
dx = L/n;
x = 0;
for i=1:n+1
A(i) = 1 + 2.2*( x - 1.5 )^2;
X(i) = x;
x = x + dx;
end
A0 = min(A);
for i=1:1 %n1
syms M
eqn = (A(i)/A0)^2 == ( 1/M^2 )*( ( 2/(gamma+1) )*( 1+0.5*(gamma-1)*M^2 ) )^( (gamma+1)/(gamma-1) )
solM = solve(eqn,M)
% Mach_is(i) = solM;
end
I commented out to loop through the entire vector since it crashes do the the output I get:
(1/root(z^6 - (40824726*z^5)/390625 + (3*z^4)/5 + (4*z^3)/25 + (3*z^2)/125 + (6*z)/3125 + 1/15625, z, 1))^(1/2)
(1/root(z^6 - (40824726*z^5)/390625 + (3*z^4)/5 + (4*z^3)/25 + (3*z^2)/125 + (6*z)/3125 + 1/15625, z, 2))^(1/2)
(1/root(z^6 - (40824726*z^5)/390625 + (3*z^4)/5 + (4*z^3)/25 + (3*z^2)/125 + (6*z)/3125 + 1/15625, z, 3))^(1/2)
(1/root(z^6 - (40824726*z^5)/390625 + (3*z^4)/5 + (4*z^3)/25 + (3*z^2)/125 + (6*z)/3125 + 1/15625, z, 4))^(1/2)
(1/root(z^6 - (40824726*z^5)/390625 + (3*z^4)/5 + (4*z^3)/25 + (3*z^2)/125 + (6*z)/3125 + 1/15625, z, 5))^(1/2)
(1/root(z^6 - (40824726*z^5)/390625 + (3*z^4)/5 + (4*z^3)/25 + (3*z^2)/125 + (6*z)/3125 + 1/15625, z, 6))^(1/2)
-(1/root(z^6 - (40824726*z^5)/390625 + (3*z^4)/5 + (4*z^3)/25 + (3*z^2)/125 + (6*z)/3125 + 1/15625, z, 1))^(1/2)
-(1/root(z^6 - (40824726*z^5)/390625 + (3*z^4)/5 + (4*z^3)/25 + (3*z^2)/125 + (6*z)/3125 + 1/15625, z, 2))^(1/2)
-(1/root(z^6 - (40824726*z^5)/390625 + (3*z^4)/5 + (4*z^3)/25 + (3*z^2)/125 + (6*z)/3125 + 1/15625, z, 3))^(1/2)
-(1/root(z^6 - (40824726*z^5)/390625 + (3*z^4)/5 + (4*z^3)/25 + (3*z^2)/125 + (6*z)/3125 + 1/15625, z, 4))^(1/2)
-(1/root(z^6 - (40824726*z^5)/390625 + (3*z^4)/5 + (4*z^3)/25 + (3*z^2)/125 + (6*z)/3125 + 1/15625, z, 5))^(1/2)
-(1/root(z^6 - (40824726*z^5)/390625 + (3*z^4)/5 + (4*z^3)/25 + (3*z^2)/125 + (6*z)/3125 + 1/15625, z, 6))^(1/2)
Can anyone suggest why am I getting this and how to solve the equation?

Matlab: How to solve a system of equations with several variables appearing multiple times

I have an equation looking like this:
w1 = (1/EI)*(heaviside(x - a1).*(((x - a1).^3)*F1(1))/6 + (C(1, 1)*x.^3)/6 + (C(2, 1)*x.^2)/2 + C(3, 1)*x + C(4, 1)) + (1/GAs).*(- heaviside(x - a1).*(x - a1)*F1(1) - C(1, 1).*x) - C(1, 1)/c_wa;
I use seven pairs of values from a measurement to solve this equation. I managed to solve it with the cftool-toolbox. But I don't really want to know the Cs, but c1, c2, k1 and k2.
I have four equations for the Cs. Now I want to solve these equations for c1, c2, k1 and k2. So far I have no clue how to do it, since the variables I want to solve for appear multiple times in each equation.
I tried to insert the four equations into my first equation and use cftool to solve it, but that does not work properly because it gets too complex.
C(1, 1) = ((c1*F*(-2*a^3*c2*(EI*(k1 + k2) + k1*k2*l) + 3*a^2*c2*k1*l*(2*EI + k2*l) + 6*a*c2*EI*l*(2*EI + k2*l) - ...
12*EI^2*(c2*l^2 + k1 + k2) - 4*c2*EI*l^3*(k1 + k2) - c2*k1*k2*l^4 - 12*EI*k1*k2*l))/ ...
(12*EI^2*(c1 + c2)*(k1 + k2) + 12*c1*c2*EI^2*l^2 + 4*c1*c2*EI*l^3*(k1 + k2) + ...
12*EI*k1*k2*l*(c1 + c2) + c1*c2*k1*k2*l^4));
C(2, 1) = ((F*k1*(2*EI*l*(a^3*c1*c2 + 6*a*k2*(c1 + c2) - 6*c2*EI) + c2*l^2*(a^3*c1*k2 - 6*a^2*c1*EI - 6*EI*k2) - ...
2*a*c1*c2*l^3*(a*k2 - 2*EI) - 6*a*EI*(c1 + c2)*(a*k2 - 2*EI) + a*c1*c2*k2*l^4))/ ...
(12*EI^2*(c1 + c2)*(k1 + k2) + 12*c1*c2*EI^2*l^2 + 4*c1*c2*EI*l^3*(k1 + k2) + ...
12*EI*k1*k2*l*(c1 + c2) + c1*c2*k1*k2*l^4));
C(3, 1) = ((EI*F*(2*EI*l*(a^3*c1*c2 + 6*a*k2*(c1 + c2) - 6*c2*EI) + c2*l^2*(a^3*c1*k2 - 6*a^2*c1*EI - 6*EI*k2) - ...
2*a*c1*c2*l^3*(a*k2 - 2*EI) - 6*a*EI*(c1 + c2)*(a*k2 - 2*EI) + a*c1*c2*k2*l^4))/ ...
(12*EI^2*(c1 + c2)*(k1 + k2) + 12*c1*c2*EI^2*l^2 + 4*c1*c2*EI*l^3*(k1 + k2) + ...
12*EI*k1*k2*l*(c1 + c2) + c1*c2*k1*k2*l^4));
C(4, 1) = ((EI*F*(2*a^3*c2*(EI*(k1 + k2) + k1*k2*l) - 3*a^2*c2*k1*l*(2*EI + k2*l) - 6*a*c2*EI*l*(2*EI + k2*l) + ...
12*EI^2*(c2*l^2 + k1 + k2) + 4*EI*l*(c2*l^2*(k1 + k2) + 3*k1*k2) + c2*k1*k2*l^4))/ ...
(12*EI^2*(c1 + c2)*(k1 + k2) + 12*c1*c2*EI^2*l^2 + 4*c1*c2*EI*l^3*(k1 + k2) + ...
12*EI*k1*k2*l*(c1 + c2) + c1*c2*k1*k2*l^4));
I would be very grateful for some hints! If this kind of problem is only solvable with Mathematica or Derive, I'd also be happy to get solutions regarding those!
EDIT (to Bill Aug 7 at 23:08):
Thanks for your reply!
the "..." means new line
EI, F1(1), GAs, F, c_wa are given variables (where did you see F?)
Therefore:
C(1, 1) = ((c1*F*(-2*a^3*c2*(EI*(k1 + k2) + k1*k2*l) + 3*a^2*c2*k1*l*(2*EI + k2*l) + 6*a*c2*EI*l*(2*EI + k2*l) - 12*EI^2*(c2*l^2 + k1 + k2) - 4*c2*EI*l^3*(k1 + k2) - c2*k1*k2*l^4 - 12*EI*k1*k2*l))/ (12*EI^2*(c1 + c2)*(k1 + k2) + 12*c1*c2*EI^2*l^2 + 4*c1*c2*EI*l^3*(k1 + k2) + 12*EI*k1*k2*l*(c1 + c2) + c1*c2*k1*k2*l^4));
C(2, 1) = ((F*k1*(2*EI*l*(a^3*c1*c2 + 6*a*k2*(c1 + c2) - 6*c2*EI) + c2*l^2*(a^3*c1*k2 - 6*a^2*c1*EI - 6*EI*k2) - ...
2*a*c1*c2*l^3*(a*k2 - 2*EI) - 6*a*EI*(c1 + c2)*(a*k2 - 2*EI) + a*c1*c2*k2*l^4))/ (12*EI^2*(c1 + c2)*(k1 + k2) + 12*c1*c2*EI^2*l^2 + 4*c1*c2*EI*l^3*(k1 + k2) + 12*EI*k1*k2*l*(c1 + c2) + c1*c2*k1*k2*l^4));
C(3, 1) = ((EI*F*(2*EI*l*(a^3*c1*c2 + 6*a*k2*(c1 + c2) - 6*c2*EI) + c2*l^2*(a^3*c1*k2 - 6*a^2*c1*EI - 6*EI*k2) - 2*a*c1*c2*l^3*(a*k2 - 2*EI) - 6*a*EI*(c1 + c2)*(a*k2 - 2*EI) + a*c1*c2*k2*l^4))/ (12*EI^2*(c1 + c2)*(k1 + k2) + 12*c1*c2*EI^2*l^2 + 4*c1*c2*EI*l^3*(k1 + k2) + 12*EI*k1*k2*l*(c1 + c2) + c1*c2*k1*k2*l^4));
C(4, 1) = ((EI*F*(2*a^3*c2*(EI*(k1 + k2) + k1*k2*l) - 3*a^2*c2*k1*l*(2*EI + k2*l) - 6*a*c2*EI*l*(2*EI + k2*l) + 12*EI^2*(c2*l^2 + k1 + k2) + 4*EI*l*(c2*l^2*(k1 + k2) + 3*k1*k2) + c2*k1*k2*l^4))/ (12*EI^2*(c1 + c2)*(k1 + k2) + 12*c1*c2*EI^2*l^2 + 4*c1*c2*EI*l^3*(k1 + k2) + 12*EI*k1*k2*l*(c1 + c2) + c1*c2*k1*k2*l^4));
Even though you don't need them to solve the problem for the understanding:
EI = 8.0934e+11
F1 = [10000 345]
=> F = F1(1) = 10000
=> a = F1(2) = 345
GAs = 7.0852e+08
c_wa = 2.115e+05;
Kind regards,
AMK

how to convert contour plot from mathematica to matlab

I am trying to draw a contour for an equation which I got from Mathematica. I was able to draw this contour easily in mathematica but not on matlab. Kindly suggest.
b=linspace(0.0005,0.0010,100);
c=linspace(0.64,0.7,100);
z=(-136*power(2.718281828459045,power(88682,c)*b)*(1 - 1/power(2.718281828459045,1*power(88682,c)*b)))/(-1+ power(2.718281828459045,power(88682,c)*b)) - 1*(power(3,c) + power(33,c) + power(146,c) + power(227,c) + power(342,c) + power(351,c) + power(353,c) + power(444,c) + power(556,c) + power(571,c) + power(709,c) + power(759,c) + power(836,c) + power(860,c) + power(968,c) + power(1056,c) + power(1726,c) + power(1846,c) + power(1872,c) + power(1986,c) + power(2311,c) + power(2366,c) + power(2608,c) + power(2676,c) + power(3098,c) + power(3278,c) + power(3288,c) + power(4434,c) + power(5034,c) + power(5049,c) + power(5085,c) + 2*power(5089,c) + power(5097,c) + power(2,1. + 3.*c)*power(5287,c) + power(5324,c) + power(5389,c) + power(5565,c) + power(5623,c) + power(6080,c) + power(6380,c) + power(6477,c) + power(6740,c) + power(7192,c) + power(7447,c) + power(7644,c) + power(7837,c) + power(7843,c) + power(7922,c) + power(8738,c) + power(10089,c) + power(10237,c) + power(10258,c) + power(10491,c) + power(10625,c) + power(10982,c) + power(11175,c) + power(11411,c) + power(11442,c) + power(11811,c) + 2.*power(12559,c) + power(12791,c) + power(13121,c) + power(13486,c) + power(14708,c) + power(15251,c) + power(15261,c) + power(15277,c) + power(15806,c) + power(16185,c) + power(16229,c) + power(16358,c) + power(17168,c) + power(17458,c) + power(17758,c) + power(18287,c) + power(18568,c) + power(18728,c) + power(19556,c) + power(20567,c) + power(21012,c) + power(21308,c) + power(23063,c) + power(24127,c) + power(25910,c) + power(26770,c) + power(27753,c) + power(28460,c) + power(28493,c) + power(29361,c) + power(30085,c) + power(32408,c) + power(35338,c) + power(36799,c) + power(37642,c) + power(37654,c) + power(37915,c) + power(39715,c) + power(40580,c) + power(42015,c) + power(42045,c) + power(42188,c) + power(45406,c) + power(46653,c) + power(47596,c) + power(48296,c) + power(49171,c) + power(49416,c) + power(50145,c) + power(52042,c) + power(52489,c) + power(52875,c) + power(53321,c) + power(53443,c) + power(54433,c) + power(55381,c) + power(56463,c) + power(56485,c) + power(56560,c) + power(57042,c) + power(62551,c) + power(62651,c) + power(62661,c) + power(63732,c) + power(64103,c) + power(64893,c) + power(71043,c) + power(74364,c) + power(75409,c) + power(76057,c) + power(81542,c) + power(82702,c) + power(84566,c) + power(88682,c))*b + 1266.5546418385234*(-1 + c) + 136.*log((136.*power(2.718281828459045,power(88682,c)*b))/(-1 + power(2.718281828459045,power(88682,c)*b))) + 136*log(b) + 136*log(c);
contour(b,c,z)
The thing to keep in mind is that Mathematica is formula-oriented and is programmed in terms of mathematical variables, while Matlab is numerically oriented and programmed in terms of matrices and arrays. To evaluate a function of two variables on a grid, it is necessary to first generate that grid explicitly in the form of arrays, and then to take care to use the element-wise operators (.*, ./ etc.) instead of the matrix operators. Here is the code:
[B, C] = meshgrid(b, c);
z = (-136*exp(power(88682,C) .* B) .* (1 - 1./exp(1*power(88682,C) .* B)))./(-1+ exp(power(88682,C) .* B)) ...
- 1*(power(3,C) + power(33,C) + power(146,C) + power(227,C) + power(342,C) + power(351,C) + power(353,C) + power(444,C) + power(556,C) + power(571,C) + power(709,C) + power(759,C) + power(836,C) + power(860,C) + power(968,C) + power(1056,C) + power(1726,C) + power(1846,C) + power(1872,C) + power(1986,C) + power(2311,C) + power(2366,C) + power(2608,C) + power(2676,C) + power(3098,C) + power(3278,C) + power(3288,C) + power(4434,C) + power(5034,C) + power(5049,C) + power(5085,C) + 2*power(5089,C) + power(5097,C) + power(2,1 + 3*C) .* power(5287,C) + power(5324,C) + power(5389,C) + power(5565,C) + power(5623,C) + power(6080,C) + power(6380,C) + power(6477,C) + power(6740,C) + power(7192,C) + power(7447,C) + power(7644,C) + power(7837,C) + power(7843,C) + power(7922,C) + power(8738,C) + power(10089,C) + power(10237,C) + power(10258,C) + power(10491,C) + power(10625,C) + power(10982,C) + power(11175,C) + power(11411,C) + power(11442,C) + power(11811,C) + 2*power(12559,C) + power(12791,C) + power(13121,C) + power(13486,C) + power(14708,C) + power(15251,C) + power(15261,C) + power(15277,C) + power(15806,C) + power(16185,C) + power(16229,C) + power(16358,C) + power(17168,C) + power(17458,C) + power(17758,C) + power(18287,C) + power(18568,C) + power(18728,C) + power(19556,C) + power(20567,C) + power(21012,C) + power(21308,C) + power(23063,C) + power(24127,C) + power(25910,C) + power(26770,C) + power(27753,C) + power(28460,C) + power(28493,C) + power(29361,C) + power(30085,C) + power(32408,C) + power(35338,C) + power(36799,C) + power(37642,C) + power(37654,C) + power(37915,C) + power(39715,C) + power(40580,C) + power(42015,C) + power(42045,C) + power(42188,C) + power(45406,C) + power(46653,C) + power(47596,C) + power(48296,C) + power(49171,C) + power(49416,C) + power(50145,C) + power(52042,C) + power(52489,C) + power(52875,C) + power(53321,C) + power(53443,C) + power(54433,C) + power(55381,C) + power(56463,C) + power(56485,C) + power(56560,C) + power(57042,C) + power(62551,C) + power(62651,C) + power(62661,C) + power(63732,C) + power(64103,C) + power(64893,C) + power(71043,C) + power(74364,C) + power(75409,C) + power(76057,C) + power(81542,C) + power(82702,C) + power(84566,C) + power(88682,C)) .* B ...
+ 1266.5546418385234*(-1 + C) + 136*log((136*exp(power(88682,C) .* B))./(-1 + exp(power(88682,C) .* B))) + 136*log(B) + 136*log(C);
contour(b, c, z)
I also took the liberty to slightly syntax-normalize and simplify your formula (e.g, power(2.718..., x) is exp(x)).
Here's the result:
If you want more contour lines, use something like contour(b, c, z, 100).
To understand what I've done here, read Array vs. Matrix operations and meshgrid from the Matlab documentation. Because .* means something else than * in Matlab, one should also take care not to have trailing decimal points in expressions, like 3.*B, though it doesn't really do any harm in that case.

sorting the roots from the solution of an equation

I have the following equation and I solve it using the Function "Solve" and the answer is as follows
syms t px py pz dx dy dz A21 A20 A19 A18 A17 A16 A15 A14 A13 A12 A11 A10 A9 A8 A7 A6 A5 A4 A3 A2 A1 Thickness;
Equation = A21.*((py +t*dy).^5) + (A20.*((py +t*dy).^4)).*(px +t*dx) + A19.*((py +t*dy).^4) + (A18.*((py +t*dy).^3)).*((px +t*dx).^2) + (A17.*((py +t*dy).^3)).*(px +t*dx) + A16.*((py +t*dy).^3) + (A15.*((py +t*dy).^2)).*((px +t*dx).^3) + (A14.*((py +t*dy).^2)).*((px +t*dx).^2) + (A13.*((py +t*dy).^2)).*(px +t*dx) + A12.*((py +t*dy).^2) + (A11.*((py +t*dy))).*((px +t*dx).^4) + (A10.*(py +t*dy)).*((px +t*dx).^3) + (A9.*(py +t*dy)).*((px +t*dx).^2) + (A8.*(py +t*dy)).*((px +t*dx)) + (A7.*(py +t*dy)) + A6.*((px +t*dx).^5) + A5.*((px +t*dx).^4) + A4.*((px +t*dx).^3) + A3.*((px +t*dx).^2) + A2.*(px +t*dx) + A1 - (pz +t*dz)
Answer = solve(S,t)
Answer = RootOf(A20*dx*dy^4*z^5 + A11*dx^4*dy*z^5 + A18*dx^2*dy^3*z^5 + A15*dx^3*dy^2*z^5 + A6*dx^5*z^5 + A21*dy^5*z^5 + 3*A18*dx^2*dy^2*py*z^4 + 3*A15*dx^2*dy^2*px*z^4 + 4*A20*dx*dy^3*py*z^4 + 2*A15*dx^3*dy*py*z^4 + 2*A18*dx*dy^3*px*z^4 + 4*A11*dx^3*dy*px*z^4 + 5*A6*dx^4*px*z^4 + 5*A21*dy^4*py*z^4 + A20*dy^4*px*z^4 + A11*dx^4*py*z^4 + A17*dx*dy^3*z^4 + A10*dx^3*dy*z^4 + A14*dx^2*dy^2*z^4 + A5*dx^4*z^4 + A19*dy^4*z^4 + 6*A18*dx*dy^2*px*py*z^3 + 6*A15*dx^2*dy*px*py*z^3 + 6*A20*dx*dy^2*py^2*z^3 + 3*A18*dx^2*dy*py^2*z^3 + 3*A15*dx*dy^2*px^2*z^3 + 6*A11*dx^2*dy*px^2*z^3 + 4*A20*dy^3*px*py*z^3 + 4*A11*dx^3*px*py*z^3 + 3*A17*dx*dy^2*py*z^3 + 2*A14*dx^2*dy*py*z^3 + 2*A14*dx*dy^2*px*z^3 + 3*A10*dx^2*dy*px*z^3 + 4*A5*dx^3*px*z^3 + 4*A19*dy^3*py*z^3 + 10*A6*dx^3*px^2*z^3 + 10*A21*dy^3*py^2*z^3 + A17*dy^3*px*z^3 + A10*dx^3*py*z^3 + A9*dx^2*dy*z^3 + A13*dx*dy^2*z^3 + A18*dy^3*px^2*z^3 + A15*dx^3*py^2*z^3 + A4*dx^3*z^3 + A16*dy^3*z^3 + 6*A18*dx*dy*px*py^2*z^2 + 6*A15*dx*dy*px^2*py*z^2 + 4*A14*dx*dy*px*py*z^2 + 2*A9*dx*dy*px*z^2 + 2*A13*dx*dy*py*z^2 + 6*A20*dy^2*px*py^2*z^2 + 3*A18*dy^2*px^2*py*z^2 + 3*A15*dx^2*px*py^2*z^2 + 6*A11*dx^2*px^2*py*z^2 + 3*A17*dy^2*px*py*z^2 + 3*A10*dx^2*px*py*z^2 + 4*A20*dx*dy*py^3*z^2 + 3*A17*dx*dy*py^2*z^2 + 4*A11*dx*dy*px^3*z^2 + 3*A10*dx*dy*px^2*z^2 + 3*A4*dx^2*px*z^2 + 3*A16*dy^2*py*z^2 + 10*A6*dx^2*px^3*z^2 + 6*A5*dx^2*px^2*z^2 + 10*A21*dy^2*py^3*z^2 + 6*A19*dy^2*py^2*z^2 + A9*dx^2*py*z^2 + A13*dy^2*px*z^2 + A8*dx*dy*z^2 + A18*dx^2*py^3*z^2 + A15*dy^2*px^3*z^2 + A14*dy^2*px^2*z^2 + A14*dx^2*py^2*z^2 + A3*dx^2*z^2 + A12*dy^2*z^2 + 4*A20*dy*px*py^3*z + 3*A17*dy*px*py^2*z + 2*A15*dy*px^3*py*z + 2*A14*dy*px^2*py*z + 2*A18*dx*px*py^3*z + 2*A14*dx*px*py^2*z + 4*A11*dx*px^3*py*z + 3*A10*dx*px^2*py*z + 2*A9*dx*px*py*z + 2*A13*dy*px*py*z + 3*A18*dy*px^2*py^2*z + 3*A15*dx*px^2*py^2*z + 2*A12*dy*py*z + 2*A3*dx*px*z + 5*A6*dx*px^4*z + 4*A5*dx*px^3*z + 5*A21*dy*py^4*z + 3*A4*dx*px^2*z + 4*A19*dy*py^3*z + 3*A16*dy*py^2*z + A8*dy*px*z + A8*dx*py*z + A9*dy*px^2*z + A20*dx*py^4*z + A17*dx*py^3*z + A13*dx*py^2*z + A11*dy*px^4*z + A10*dy*px^3*z + A7*dy*z + A2*dx*z - dz*z + A9*px^2*py + A20*px*py^4 + A17*px*py^3 + A13*px*py^2 + A11*px^4*py + A10*px^3*py + A8*px*py + A18*px^2*py^3 + A15*px^3*py^2 + A14*px^2*py^2 - pz + A6*px^5 + A5*px^4 + A4*px^3 + A21*py^5 + A3*px^2 + A19*py^4 + A16*py^3 + A12*py^2 + A7*py + A2*px + A1, z)
Is there any way to sort the roots in order to apply later the function "roots"? Or is there anyway to get the roots out of this Answer = RootOf(.......
I have all the variables at the end but they are quite a lot that's why I have to solve it generally before and then apply for loop to get the roots.
Many thanks in advance
This is the answer that no body could give it to me and I got vote down for it:
a = char(Answer); % Convert from symbolic to String
R = strrep(a,'RootOf(',''); % Preparing the Expression to be ready to get the Coefficients
R1 = strrep(R,', z)',''); % Preparing the Expression to be ready to get the Coefficients
b = sym(R1); % converting back to Symbolic
Coeff = coeffs(b,z); % I got the Coefficients