How can I plot with a for data named h1-h10?

3 visualizaciones (últimos 30 días)
Michael
Michael el 11 de Abr. de 2022
Comentada: Voss el 11 de Abr. de 2022
I have some data named h1,h2,....,h10. I want to plot them seperately in different figures. I have done this and it does not work, which I think is because of an incorrect way of using num2str. What can I do to correct it?
x=-0.21:0.01:0.21;
h=0.098;
L=0.447;
g=9.81;
for i=1:1:10
j=num2str(i);
figure
parabola=h+omegah(i)^2/(2*g)*(x.^2-L^2/12);
plot(x,parabola)
hold on
plot(xj,hj)
end

Respuesta aceptada

Voss
Voss el 11 de Abr. de 2022
Looks like you might have x1, x2, ..., x10 as well. If not, you can modify this accordingly.
h_all = {h1 h2 h3 h4 h5 h6 h7 h8 h9 h10};
x_all = {x1 x2 x3 x4 x5 x6 x7 x8 x9 x10};
x=-0.21:0.01:0.21;
h=0.098;
L=0.447;
g=9.81;
for i=1:1:10
figure
parabola=h+omegah(i)^2/(2*g)*(x.^2-L^2/12);
plot(x,parabola)
hold on
plot(x_all{i},h_all{i});
end
  2 comentarios
Michael
Michael el 11 de Abr. de 2022
Thanks!
Voss
Voss el 11 de Abr. de 2022
You're welcome!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Annotations en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by