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

Walter Roberson
Walter Roberson 2018년 4월 29일
Your code outline does not show velocity being recomputed. Also, "n" and "N" are not the same.
Zwithouta
Zwithouta 2018년 4월 29일
편집: Zwithouta 2018년 4월 29일
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
dpb
dpb 2018년 4월 29일
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???
Walter Roberson
Walter Roberson 2018년 4월 30일
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

댓글을 달려면 로그인하십시오.

답변 (1개)

Roee Ben Shlomo
Roee Ben Shlomo 2018년 5월 3일

0 개 추천

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

카테고리

도움말 센터File Exchange에서 Scatter Plots에 대해 자세히 알아보기

질문:

2018년 4월 29일

댓글:

2024년 8월 17일

Community Treasure Hunt

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

Start Hunting!

Translated by