Calling function in the same script to plot graph
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Nur Adilah Ismail
el 29 de Dic. de 2020
Comentada: Nur Adilah Ismail
el 1 de En. de 2021
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 comentarios
Respuesta aceptada
Cris LaPierre
el 29 de Dic. de 2020
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');
Más respuestas (0)
Ver también
Categorías
Más información sobre 2-D and 3-D Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!