plotting using fsolve in a for loop (2 variables)
이전 댓글 표시
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 ?
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Programming에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
