How can I plot (scatter diagram) three data series at the same time?

조회 수: 2 (최근 30일)
Hans Lipton
Hans Lipton 2021년 10월 27일
댓글: Hans Lipton 2021년 10월 27일
Good day all,
I have following dataset. Now I would like to plot the data using scatter. X axis is temperature and Y axis is molality. The data set includes a wide range of different pressures (0 to 20.000 bar) and I would like to create plots (scatter) in which you can find the temperature-molality diagrams depending with the same pressure value. So e.g. diagram 1 includes all temperature-molality relation with 500 bar, diagram 2 includes all l temperature-molality relation with 1000 bar and so on.
Many thanks for your support.
  댓글 수: 1
Hans Lipton
Hans Lipton 2021년 10월 27일
I am very new to Matlab, so I would be very happy if you could add a code, too. Many thanks!

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

채택된 답변

Johan
Johan 2021년 10월 27일
Hello Robert,
You can use conditional statement inside an array call to filter it with your wanted data:
myarray = [500,1,2;500,2,3;500,4,2;1000,4,5;1000,6,7]
myarray = 5×3
500 1 2 500 2 3 500 4 2 1000 4 5 1000 6 7
%filter for 500 in first column
%the conditional statement abs(myarray(:,1)-condition)<eps looks for values of
%myarray that are less than 1 epsilon away from condition
condition = 500;
myarray(abs(myarray(:,1)-condition)<eps,:)
ans = 3×3
500 1 2 500 2 3 500 4 2
%plot conditional data
figure(1)
plot(myarray(abs(myarray(:,1)-condition)<eps,2), myarray(abs(myarray(:,1)-condition)<eps,3),'x-')
figure(2)
condition = 1000;
plot(myarray(abs(myarray(:,1)-condition)<eps,2), myarray(abs(myarray(:,1)-condition)<eps,3),'x-')
Hope this helps.
  댓글 수: 1
Hans Lipton
Hans Lipton 2021년 10월 27일
I am very happy about your support, this helps a lot. Many thanks, Johan!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Scatter Plots에 대해 자세히 알아보기

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by