Calling function in the same script to plot graph
조회 수: 3 (최근 30일)
이전 댓글 표시
I have this function
function z=Fun(u)
d=length(u);
a1=1000
b1= 16.19
c1=0.00048
a2=700
b2=16.6
c2=0.002
a3=680
b3=16.5
c3=0.00211
a4=370
b4=22.26
c4=0.0072
a5=660
b5=25.92
c5=0.00413
p1max=455
p2max=130
p3max=130
p4max=80
p5max=55
pd=480
p1=u(1)
p2=0
p3=0
p4=0
p5=pd-p1
z=a1 + (b1*p1) + c1*(p1)^2 + a5 + (b5*p5) + c5*(p5)^2 +60
I would like to call the z value in another function to plot graph z vs iteration
plot(N_iter,z); %N_iter is the number of iteration
xlabel('Iteration');
ylabel('Cost');
댓글 수: 0
채택된 답변
Cris LaPierre
2020년 12월 29일
You would need to first call the function and capture its output in a variable named z.
in = ???;
z = Fun(in);
plot(N_iter,z); %N_iter is the number of iteration
xlabel('Iteration');
ylabel('Cost');
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!