How do I plot table with subplot?

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?
Emmanuel Matata Bili Bili
Emmanuel Matata Bili Bili 2020 年 10 月 23 日
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.
Emmanuel Matata Bili Bili
Emmanuel Matata Bili Bili 2020 年 10 月 25 日
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.
Emmanuel Matata Bili Bili
Emmanuel Matata Bili Bili 2020 年 10 月 27 日
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 件のコメント

Emmanuel Matata Bili Bili
Emmanuel Matata Bili Bili 2020 年 10 月 23 日
Hi Cris,
Thanks for the feedback. I checked it out and I'm able to do the provided exercises in MATLAB Onramp.

サインインしてコメントする。

カテゴリ

Community Treasure Hunt

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

Start Hunting!

Translated by