I want to plot Date and time against the power production, every variable has the lenght of 13104.
But if i want to plot this error come up :
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Error using reshape
To RESHAPE the number of elements must not change.
Error in Bachelorarbeit (line 173)
z=reshape(POutput,length(y),length(x));
%%%%%%%%%%%%%%%%%%%%%%
ttab=table(Date1,t,POutput); % compare everything has the same length
% creating the parameter
x=unique(Date1); %returns the data, but without repetition
y=unique(t); %returns the data, but without repetition
z=reshape(POutput,length(y),length(x));
%creating the matrix z length(x)
%returns the length of the largest array dimension in x and y
% creating a surface plot
surf(x,y,z,'Facecolor','interp') %create a surface plot
colorbar % add a colorbar
colormap(jet) % adjust the colorrange from the surface plot
zlabel('Leistung in MW') %label the z-axis
%print('Usage','-dpng') % if you want to save the plot

 Réponse acceptée

Stephan
Stephan le 1 Déc 2018
Modifié(e) : Stephan le 1 Déc 2018

0 votes

Hi Felix,
i hope the work on your thesis runs well. As the error message says the number of elements in a reshaped matrix is not allowed to change:
>> A = randi(3,1,6)
A =
3 2 2 1 3 1
>> B =reshape(A,2,[])
B =
3 2 3
2 1 1
my example shows that you can leave away one dimension - reshape claculates the needed number of columns in this case. The following will produce error, because there are only 6 elements in A instead of 8:
>> B =reshape(A,2,4)
Error using reshape
To RESHAPE the number of elements must not change.
The command above would cause a 2x4 matrix but A has only 6 - so the result is an error. Check your code in terms of this problem. To make it more precise it seems that the prodct of
length(y) * length(x)
is not equal to:
numel(POutput)
which causes this error.
Best regards & always good weather ;-)
Stephan

Plus de réponses (0)

Catégories

En savoir plus sur Line Plots dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by