Effacer les filtres
Effacer les filtres

Info

Cette question est clôturée. Rouvrir pour modifier ou répondre.

Matlab Plotting Error Problem

1 vue (au cours des 30 derniers jours)
John
John le 6 Avr 2014
Clôturé : MATLAB Answer Bot le 20 Août 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.

Réponses (2)

Youssef  Khmou
Youssef Khmou le 6 Avr 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 le 6 Avr 2014
Modifié(e) : Image Analyst le 6 Avr 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;

Cette question est clôturée.

Tags

Aucun tag saisi pour le moment.

Community Treasure Hunt

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

Start Hunting!

Translated by