MATLAB Answers

How to solve Index in position 1 exceeds array bounds (must not exceed 1).

4 views (last 30 days)
Hello,
When I am trying to run my code in matlab 2020a version I am getting this error. but when I am running the same code in matlab 2018b version, it runs normally. why am i getting this error and how can i solve this error. Please guide me.
With regards,

  6 Comments

Show 3 older comments
vishnuvardhan naidu tanga
vishnuvardhan naidu tanga on 19 Jun 2020
hello again,
I have gone through the code. the code crashes at line. here the p0_A_SOEC_INIT is a constant value and after simulation the p0_A_SOEC_INIT_out is calculated at every time step and the final value of the simulation is considered. In my case the p0_A_SOEC_INIT always remains constant through out the system. but It has to be a vector. if i run in old versions p0_A_SOEC_INIT_out is stored as a vector in the workspace. In 2020a version it is storing as a single scalar value.
p0_A_SOEC_INIT = p0_A_SOEC_INIT_out(n_IC_SOEC,:);

Sign in to comment.

Accepted Answer

David Hill
David Hill on 19 Jun 2020
You could always store it as a vector in the size you need it.
p0_A_SOEC_INIT_out=p0_A_SOEC_INIT_out*ones(1,size_you_need);

More Answers (0)