Error using reshape and permute

3 visualizzazioni (ultimi 30 giorni)
Macon Pharr
Macon Pharr il 29 Mar 2019
Commentato: Macon Pharr il 29 Mar 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.

Risposta accettata

Kevin Phung
Kevin Phung il 29 Mar 2019
a 17*11*11 matrix contains 2057 elements, you have 1800.
  1 Commento
Macon Pharr
Macon Pharr il 29 Mar 2019
You’re right. I updated the size of the matrix after I had posted it, but the data points are still wildly different.
I’m going to have to do some interpolating to increase the length of the matrix to get the reshape to work.

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Guidance, Navigation, and Control (GNC) in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by