I need help plotting using this while loop
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Daabir Momin
el 27 de Mzo. de 2023
Comentada: Daabir Momin
el 27 de Mzo. de 2023
this is how my code looks like currently, I am generating the correct munbers for the fuction but it is not plotting anything. Please Help.
xx = linspace(-5,9,85);
w=0
while w<85
w=w+1;
fxx = ((xx(w)+1)^2)./(2+5*xx(w));
end
plot(xx,fxx)
0 comentarios
Respuesta aceptada
VBBV
el 27 de Mzo. de 2023
xx = linspace(-5,9,85);
w=0
while w<85
w=w+1;
fxx(w) = ((xx(w)+1)^2)./(2+5*xx(w));
end
plot(xx,fxx)
2 comentarios
VBBV
el 27 de Mzo. de 2023
Use an counter to create array for the variable you want to plot. if you use
xx = linspace(-5,9,85)
w = 1; %e.g.
fxx = ((xx(w)+1)^2)./(2+5*xx(w)) % a single value
it will of course evaluate the equation inside the while loop but does not create an array of values but only a scalar value. Read more about plot function in This link
Más respuestas (0)
Ver también
Categorías
Más información sobre Loops and Conditional Statements 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!

