Info

This question is closed. Reopen it to edit or answer.

Matlab Plotting Error Problem

2 views (last 30 days)
John
John on 6 Apr 2014
Closed: MATLAB Answer Bot on 20 Aug 2021
Hi everyone, I have encountered an error in plotting graph. It says Data must be a single matrix Y or a list of pairs X,Y.
The following is my code. Hour = linspace(1,24,24);
Clementi_Primary_School = [31109 30599 30599 30599 30599 45899 66298 137697 152996 143817 150446 147896 150956 155546 156056 151976 139227 112197 85678 61199 55079 50999 45899 41309];
Clementi_Primary_School_24Hrs = [2204675];
plot(Hour,Clementi_Primary_School,Clementi_Primary_School_24Hrs);
Please advise me on what I can do to solve this problem.

Answers (2)

Youssef  Khmou
Youssef Khmou on 6 Apr 2014
Graph of one dimensional function is made with vectors X,Y with the same length,
add this to your program :
Clementi_Primary_School_24Hrs = [2204675]*ones(size(Clementi_Primary_School));

Image Analyst
Image Analyst on 6 Apr 2014
Edited: Image Analyst on 6 Apr 2014
Try this:
Hour = linspace(1,24,24);
Clementi_Primary_School = [31109 30599 30599 30599 30599 45899 66298 137697 152996 143817 150446 147896 150956 155546 156056 151976 139227 112197 85678 61199 55079 50999 45899 41309];
Clementi_Primary_School_24Hrs = repmat(2204675, 1, length(Hour));
plot(Hour,Clementi_Primary_School,Hour,Clementi_Primary_School_24Hrs, 'LineWidth', 3);
grid on;

Tags

No tags entered yet.

Community Treasure Hunt

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

Start Hunting!