Plotting graph with excel file

조회 수: 2 (최근 30일)
asd ad
asd ad 2020년 8월 6일
댓글: asd ad 2020년 8월 6일
RunNo
figure (2)
plot(t(a),CAD(a),'Linewidth',2)
hold on
plot (RunNo2,CAL2,'Linewidth',2)
grid on
xlabel ('Time (s)')
ylabel ('\theta (\circ)')
title ('Contact Angle vs Evaporation Time')
legend('Theoretical','Experimental')
Time CA1 CA2
0 53.34 53.34
78 44.64 44.23
143 37 37.22
207 34.63 34.56
240 32.57 35.64
280 29.54 33.97
356 27.61 31.57
420 24.66 27.34
456 22.86 29.43
500 19.18 14.17
534 15.13 21.49
560 11.13 15.78
600 0 0
Hello everyone,
I have these values from excel and I want to plot them on matlab. When I use the plot function it just plots it as time 1,2,3,4... instead of the numbers in the data above. Furthermore, I'm using a hold on command in my plot. This is because I want to plot the experimental values above along with the theoretical values provided by the model. How do I just plot the above points on to my model at the time provided? I have attached the code to this question.
Thanks

채택된 답변

Cris LaPierre
Cris LaPierre 2020년 8월 6일
We'll have to make some assumptions, since we don't have all the details.
I'm going to assume your data is in a table with 3 variables, Time, CA1, and CA2. I'll assume that table is named 'Data'.
plot(Data.Time, Data.CA1)
hold on
plot(Data.Time, Data.CA2)
hold off
When you don't specify the X values in your plot command, MATLAB plots Y against it's index number (1, 2, 3, ...).
  댓글 수: 1
asd ad
asd ad 2020년 8월 6일
It worked
thank you

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

추가 답변 (0개)

카테고리

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