Hi everyone,
I have a simple 1x3 table
T=[35 40 45]
Below is a sample syntax from class (not my code).
I'm trying to figure out how to use x and y1 based on the code below.
Also how I could use subplot if I have multiple rows and columns.
I appreciate all the help. Thanks.
x = linspace(-2*pi, 2*pi)
y1 = sin(x);
plot(x,y1)

댓글 수: 5

madhan ravi
madhan ravi 2020년 10월 23일
What you have is an array with 3 elements, you need to elaborate what you want to do with those three values?
Hi Ravi,
Thanks for the quick reply.
The 3 elements are temperatures in 3 different cities.
The first column is let's sayToronto, column 2 is Montreal and 3 is Vancouver.
I'm able to plot the data and get a line. But I'm trying to get a sin wave instead. I'm wondering if that's possible.
Hi Guys,
I took time to think about the problem then drew on paper to understand the problem better. I was able to figure it out.
My code below.
Temp_T = [25 35 35 30 30]; %Temperature Toronto
T = [2 3 4 5 6]; %Time between 2PM- 6PM
subplot(1,6,1)
x = T
y1 = Temp_T
plot(x,y1, 'LineStyle','--','color','g','Marker','o','MarkerSize',5)
xlabel('Time 2:00 PM - 6:00 PM')
ylabel('Toronto','Color','blue')
title('temperature from 2:00 PM - 6:00 PM')
hold on
subplot(1,6,2)
Temp_Cal = [20 22 25 25 23]; %Temperature Calgary
y2 = Temp_Cal;
plot(x,y2,'LineStyle',':','color','r','Marker','*','MarkerSize',5)
ylabel('Calgary','Color','blue')
hold on
subplot(1,6,3)
Temp_V = [19 21 20 19 17]; %Temperature Vancouver
y3 = Temp_V;
plot(x,y3,'LineStyle',':','color','r','Marker','+','MarkerSize',5)
ylabel('Vancouver','Color','blue')
hold off
Cris LaPierre
Cris LaPierre 2020년 10월 25일
You do not need the hold on and hold off commands.
Sounds good.
Thanks Cris!!

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

답변 (1개)

Cris LaPierre
Cris LaPierre 2020년 10월 23일

0 개 추천

I recommend going through MATLAB Onramp. Chapter 9 covers plotting, but it sounds like some of the other chapters would be helpful as well.

댓글 수: 1

Hi Cris,
Thanks for the feedback. I checked it out and I'm able to do the provided exercises in MATLAB Onramp.

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

카테고리

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

질문:

2020년 10월 23일

댓글:

2020년 10월 27일

Community Treasure Hunt

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

Start Hunting!

Translated by