loop in two matrices for extracting values and plot lines
1 回表示 (過去 30 日間)
古いコメントを表示
Hello everyone,
I would like to extract the values stored in 2 different matrices and use them in order to create a line (plot). One point should be always the same (I1,M1) where I1 is the x coordinate and M1 is the Y.
inside J and WZ matrices, I have, let's say, 3 values each (but they could be more or less) and I would like to use them in order to create 3 different lines with one point constant (I1, M1) while the others change. PLease note that, I would like to add 2500 to all the values stored inside WZ.
J = [2.5 27 56];
WZ = [12.2 23.2 33];
M1 = 22
I1 = 2600
in this specific case, I would end up with 3 lines as follow:
line_1 = line([I1;(12.2+2500)],[M1;2.5])
line_2 = line([I1;(23.2+2500)],[M1;27])
line_3 = line([I1;(33+2500)],[M1;56)
the following line of code is useless as I get the following results: Dimensions of arrays being concatenated are not consistent.
thanks for your help!
for peaks = length(WZ)
plot([I1;(WZ+2500)],[M1;J])
0 件のコメント
採用された回答
Voss
2022 年 12 月 8 日
J = [2.5 27 56];
WZ = [12.2 23.2 33];
M1 = 22;
I1 = 2600;
for ii = 1:numel(WZ)
line([I1;WZ(ii)+2500],[M1;J(ii)]);
end
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Line Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!