Error using reshape and permute
3 views (last 30 days)
Show older comments
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 Comments
Accepted Answer
More Answers (0)
See Also
Categories
Find more on Resizing and Reshaping Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!