plz help me check the this error. Warning: Unable to solve symbolically. Returning a numeric solution using vpasolve.

6 views (last 30 days)
plz help me to check the error,
I dont know anything wrong.
thank you
%define the functon\\
clear
syms y1 y2 y z t t1 t2 h z1 z2
S1 = -y*exp(-10/(z+273));
S2 = y*1000*exp(-10/(z+273))-10*(z-20);
SS1 = y2 - y1 - h*subs(S1,{y z},[y2 z2]);
SS2 = z2 -z1 - h*subs(S2,{y z},[y2 z2]);
EQN1 = SS1 ==0
Y = solve(EQN1, y2);
EQN2 = SS2 ==0
Z = solve(EQN2, z2);
%solve the system\\
H=0.2;
T=0:H:10;
YN(1)=1;
ZN(1)=15;
fprintf('------------------------------------------\n');
fprintf(' S.No. h\t\t y1\t\t\t y2\t\n');
fprintf('------------------------------------------\n');
fprintf(' 1.0 \t %4.4f \t \t %4.4f \t %4.4f \n', T(1), YN(1), ZN(1));
for i = 2: length(T)
EQ1 = subs(EQN1,{y1 z1 h t}, [YN(i-1) ZN(i-1) H T(i)]);
EQ2 = subs(EQN2,{y1 z1 h t}, [YN(i-1) ZN(i-1) H T(i)]);
[solx,soly] = solve(EQ1,EQ2);
YN(i) = double(solx);
ZN(i) = double(solx);
fprintf(' %4.1f\t %4.4f\t\t $r.rf\t\t %4.4f\t\n',i,T(i),YN(i),ZN(i));
end
fprintf('===============================\n');
%define the analytical function\\
%%
%Solve the analytical solution\\
[time,p]=ode45(@fun1,[0,10],[1 15]);
%Plot the solution\\
TIT=['MATLAB Solution;']; XL='t'; YL='y';
figure('units','normalized','Position', [0.1 0.1 0.7 0.8])
plot(T,YN,'b','Linewidth',2)
hold on
plot(time,p(:,1),'r','Linewidth',2)
plot(T,ZN,'-ob','Linewidth',2)
hold on
plot(time,p(:,2),'-or','Linewidth',2)
hold on
grid on
box on
xlabel(XL)
ylabel(YL)
title(TIT)
grid on
set(gca,'FontSize',20)
legend('CA1','CA2','CB1','CB2','Location','NorthEast')
ST=char(datetime('now'));
print(['Plot1.png'],'-dpng')
function Dp=fun1(t,p)
y=p(1);z=p(2);
Dp = [ -y*exp(-10/(z+273)); y*1000*exp(-10/(z+273))-10*(z-20)];
% Dp=Dp';
end

Answers (1)

Ameer Hamza
Ameer Hamza on 13 Apr 2020
This is not an error. It is just a warning by MATLAB that it is not able to find a symbolic solution, so it is returning the numeric solution. If you only care about the value of the solution, then this should not be an issue. You can suppress this warning by changing line 31 in your code to
[solx,soly] = vpasolve(EQ1,EQ2);

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!