plotting using fsolve in a for loop (2 variables)
Show older comments
I want to plot two equations in terms of one parameter z that goes from 0.1 to 1. For that, I used fsolve in a for loop. When I run my code, it says that the equation is solved but there is no line line on my graph.
Here is my code:
P_1;
k=25;
a=-0.0075;
b=0.1750;
c=4;
z=linspace(0.1,1);
for z=1:length(z);
f@(x) compressorcharacteristic(x, z, k, P_, a, b, c);
xguess=[1.1,10];
sol=fsolve(f,xguess);
mdot_sol=sol(1);
P_sol=sol(2);
end
plot(z,mdot_sol);
hold on
plot(z,P_sol);
hold off
function y=compressorcharacteristic(x,P_,k,a,b,c,z)
mdot=x(1);
P=x(2);
y(1)=z.*k.*sqrt(P-P_)-mdot;
y(2)=a.*(mdot.^2)+b.*mdot+4-P;
end
Can someone pinpoint the problem ?
Accepted Answer
More Answers (0)
Categories
Find more on Programming in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!