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!