Plotting a limited number of elements

2 ビュー (過去 30 日間)
Ana Carolina da Silva Pacheco
Ana Carolina da Silva Pacheco 2021 年 5 月 17 日
I have the code below:
it=10;
n=3;
jvals=zeros(it,n);
vetor_momentoj=zeros(it,n);
aux=1;
for i=1:it
jvals(i,:)=linspace(0,0.03,n);
for j=1:n
curvatura=jvals(i,j);
x0j = 1;
vetor_momentoj(i,j)=aux;
aux=aux+1;
end
plot(jvals(i,:), vetor_momentoj(i,:), '-o'), hold all
end
disp(jvals);
disp(vetor_momentoj);
I'm plotting a jvals x vetor_momentoj curve. The problem is that I don't want to plot all the 10 (it=10) interactions, I only want to plot the first 5, for example. How can I do it?

採用された回答

per isakson
per isakson 2021 年 5 月 17 日
"plot the first 5" An if-statement should do that. Replace
plot(jvals(i,:), vetor_momentoj(i,:), '-o'), hold all
by
if i <= 5
plot(jvals(i,:), vetor_momentoj(i,:), '-o'), hold all
end
  1 件のコメント
Ana Carolina da Silva Pacheco
Ana Carolina da Silva Pacheco 2021 年 5 月 17 日
Thank you so much!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by