Error using reshape and permute
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Macon Pharr
el 29 de Mzo. de 2019
Comentada: Macon Pharr
el 29 de Mzo. de 2019
I have reqwritten a script where I want to reshape data from an engine deck to use for for some colormaps. I am currently recieving this error "To RESHAPE the number of elements must not change." where i have specificed in the code. I am trying to reshape the data to a 17x11x11 array, but I cant figure out what is wrong.
The reshape function is currently structured as reshape((924x1),[11,11,17])
function [thrust,fuelflow,tsfc]=cf34(M,h,pc)
if nargin<3;error('You must specify 3 inputs (M,h,pc)');end
if ~all((size(h) == size(M)) & (size(pc) == size(M)));error('Input matrices M, h, and pc must all be the same size');end
deck=makedeck; %924x6 double
%get full factorial dimensions
dims=[numel(unique(deck(:,1))) numel(unique(deck(:,2))) numel(unique(deck(:,3)))]; %[17, 11, 11] 17 unique values for data in column 1, 11 unique values for column 2 and column 3
%make grid of unique points
[Mdata hdata pcdata]=ndgrid(unique(deck(:,1)),unique(deck(:,2)),unique(deck(:,3))); % creates a 17x11x11 double matrix
%where the code is erroring:
thrustdata=permute(reshape(deck(:,4),fliplr(dims)),[3 2 1]);
fuelflowdata=permute(reshape(deck(:,5),fliplr(dims)),[3 2 1]);
tsfcdata=permute(reshape(deck(:,6),fliplr(dims)),[3 2 1]);
>> thrustdata=permute(reshape(deck(:,4),[fliplr(dims)]),[3 2 1]);
Error using reshape
To RESHAPE the number of elements must not change.
0 comentarios
Respuesta aceptada
Más respuestas (0)
Ver también
Categorías
Más información sobre Resizing and Reshaping Matrices en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!