Plotting vectors making chart

1 view (last 30 days)
Vc27
Vc27 on 17 Nov 2022
Edited: Voss on 18 Nov 2022
I have a 25x5 matrix, M, I want to obtain values from the third column which are >1.5, <0.5, and the remaining values of the third column. I would ideally like to plot them in different colors on the same graph. so far I have got this but I don't think its correct, N=M(:,3) if N>1.5 plot(N, 'r') hold on if N<0.5 plot(N, 'b') hold on plot(N, 'g') end
Thanks

Accepted Answer

Voss
Voss on 17 Nov 2022
Maybe something like this?
M = randn(100,5); % some random data for demo
N = M(:,3);
idx = find(N > 1.5);
plot(idx, N(idx), 'r.')
hold on
idx = find(N < 0.5);
plot(idx, N(idx), 'b.')
idx = find(N >= 0.5 & N <= 1.5);
plot(idx, N(idx), 'g.')
  4 Comments
Voss
Voss on 17 Nov 2022
You're welcome!

Sign in to comment.

More Answers (0)

Categories

Find more on 2-D and 3-D Plots in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!