How do I scatter twice on the same graph?

Hello,
I have 2 vectors with numbers: velocity(815x1) and velocityTimes(815x1). Velocity is calculated, among the other parameters, with a variable N which also changes the way it looks when scattered.
I need to scatter velocity and velocityTimes once, change N, and then on the same graph scatter it again with the new N.
However I can't seem to get it right.
What I'm trying to do is this:
n = 2
figure(1)
scatter(velocityTimes,velocity)
hold on
n = 150
scatter(velocityTimes,velocity)
But it only scatters the first one, with n=2. How do I fix it?
Thanks very much in advance!

7 Comments

Your code outline does not show velocity being recomputed. Also, "n" and "N" are not the same.
Recompute velocity (see example code)
velocity = ones(815,1); % velocity vector
n = 2;
velocity = velocity*n; % example formula
figure(1)
scatter(velocityTimes,velocity)
n = 150; % redefine n
velocity = velocity*n; % recomputate velocity!!!
hold on
scatter(velocityTimes,velocity)
hold off
And the result is?
Nothing appears amiss other than the plots are going to be very uninteresting given the data and operation thereon but certainly should be two shown. Perhaps if you physically change the color of the second to ensure you can distinguish the two???
velocity*n the first time is going to be all 2s, which would lead to a horizontal series at 2.
velocity*n the second time is going to multiply those 2s by 150, leading to all 300s, which would then give a horizontal series at 300.
Are you sure you want the two different n values to be multiplied together? Or should you be taking a copy of the original velocity and use that to calculate the second velocity ?
Hello. I am trying to plot similar multiple scatter at the same plot, but it showing error.
scatter(time_vector_ev2,baz_lines_ev2,50,back_azm_ev2_error, 'LineWidth',1.5)
hold on
scatter(time_vector_ev1,baz_lines_ev1,50,back_azm_ev2_error,"filled", 'LineWidth',1.5)
the time_vector_ev2 and baz_lines_ev2 has 1x33 size, while time_vector_ev1 and baz_lines_ev1 is 1x9. They are the same information. However, the time_vector_ev1 and baz_lines_ev1 has just a short information range of the time_vector_ev2 and baz_lines_ev2 that should be highlighted on plot. So, I am using the "filled" to change the circles. The time_vector_ev1 and baz_lines_ev1 would be the values from 13 to 21 position of the 1x33 matrix referent to the time_vector_ev2 and baz_lines_ev2.
Does someone know how I can do there? Thanks in advance!
The number of elements in x and y must match the number of elements in sz (with some exceptions for the case of matrix x and y and vector sz.)
If back_azm_ev2_error matches the size of time_vector_ev2 for the first call, then it is not going to match the size of time_vector_ev1 for the second call, but you used back_azm_ev2_error as the sz for both calls.
Yes, that was the so simple problem that I did not see. thank you very much

Sign in to comment.

Answers (1)

Thank you very much. looking back it was a foolish mistake of mine.

Asked:

on 29 Apr 2018

Commented:

on 17 Aug 2024

Community Treasure Hunt

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

Start Hunting!