error with "reshape"

1 view (last 30 days)
za
za on 2 Jun 2017
Answered: KSSV on 2 Jun 2017
% Set parameters
H=36;
ns=47;
% n=37;
% Data are sorted as:
% [oil1,ci1_5,ci1_10,oil2,ci2_5,ci2_10]
% for each column, (2H+2) IRFs, from sect=1 to sect=ns.
oil1=data(:,1);
ci1_5=data(:,2);
ci1_10=data(:,3);
oil2=data(:,4);
ci2_5=data(:,5);
ci2_10=data(:,6);
oil1=reshape(oil1,2*H+2,ns);
ci1_5=reshape(ci1_5,2*H+2,ns);
ci1_10=reshape(ci1_10,2*H+2,ns);
oil2=reshape(oil2,2*H+2,ns);
ci2_5=reshape(ci2_5,2*H+2,ns);
ci2_10=reshape(ci2_10,2*H+2,ns);
What's wrong in using reshape in the above context?

Answers (1)

KSSV
KSSV on 2 Jun 2017
Read the documentation of reshape. When you reshape a array with n elements, the resultant reshaped array too should have n elements. If they are not in match, error pops.
In your case, you are trying to reshape into a array, in which the above condition is not satisfying.

Categories

Find more on Startup and Shutdown 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!