load x,y

조회 수: 7 (최근 30일)
abdullah qasim
abdullah qasim 2020년 11월 17일
댓글: abdullah qasim 2020년 11월 18일
if x = [1 2 3 ...... 10]
y1=[0.5 1.7 1.75 1.9 2 2.1 2.4 2.6 2.7 2.9 ]
y2=[0.7 1.8 1.9 2 2.3 2.5 2.7 2.8 2.9 3]
how can I make save (x,y) and (x,y1) then do load it
then plot it

채택된 답변

Star Strider
Star Strider 2020년 11월 17일
편집: Star Strider 2020년 11월 17일
Try this:
x = 1:10;
y1=[0.5 1.7 1.75 1.9 2 2.1 2.4 2.6 2.7 2.9 ]
y2=[0.7 1.8 1.9 2 2.3 2.5 2.7 2.8 2.9 3]
save('XYvectors.mat','x','y1','y2')
D = load ('XYvectors.mat');
x = D.x;
Y1 = D.y1;
y2 = D.y2;
Use whatever file name you want.
See the documentation for the plot function.

추가 답변 (1개)

Timo Dietz
Timo Dietz 2020년 11월 17일
There are certainly different ways to do so.
E.g.:
x = 1:1:10;
y1=[0.5 1.7 1.75 1.9 2 2.1 2.4 2.6 2.7 2.9 ];
y2=[0.7 1.8 1.9 2 2.3 2.5 2.7 2.8 2.9 3];
save('filename', 'x', 'y1', 'y2') ;
data = load('filename');
plot(data.x, data.y1);
plot(data.x, data.y2);
  댓글 수: 5
Timo Dietz
Timo Dietz 2020년 11월 18일
편집: Timo Dietz 2020년 11월 18일
For plotting multiple traces in one diagram, use the "hold" command in order to prevent the plot from being cleared:
plot(data.x, data.y1);
hold on;
plot(data.x, data.y2);
abdullah qasim
abdullah qasim 2020년 11월 18일
thank u

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

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by