Info

Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.

Matlab Plotting Error Problem

3 Ansichten (letzte 30 Tage)
John
John am 6 Apr. 2014
Geschlossen: MATLAB Answer Bot am 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.

Antworten (2)

Youssef  Khmou
Youssef Khmou am 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 am 6 Apr. 2014
Bearbeitet: Image Analyst am 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

Noch keine Tags eingegeben.

Community Treasure Hunt

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

Start Hunting!

Translated by