Effacer les filtres
Effacer les filtres

How can I increase vector size of the output from 7 x 7 double to 30 x 7 double i.e how can I make a for-loop to repeat 30 times?

1 vue (au cours des 30 derniers jours)
Hi all, How can I increase the size of the output vector of the attached m-file (EulerMethod.m) from 7 x 7 double to 30 x 7 double. I actually need each variable in y0 to have 30 rows, that is, I need the for-loop to repeat 30 times. How can I do that? The file also calls other m-files, namely, Hion.m, C_Bulk.m , odes.m and Parameters.m, which are also attached.
Kind Regards Dursman
  3 commentaires
KSSV
KSSV le 9 Oct 2018
Have a look on interp1 if you are looking for interpolation.
Dursman Mchabe
Dursman Mchabe le 9 Oct 2018
Thanks a lot for the response, I have to quickly read/learn about Pad array or interpolation.
I think I am simply failing to make my loop to repeat 30 times.

Connectez-vous pour commenter.

Réponse acceptée

Walter Roberson
Walter Roberson le 9 Oct 2018
You don't.
You initialized y0 to a 1x7 and then transpose it so that it is 7x1.
In your loop you call odes, which returns a 7x1. You transpose that to 1x7, and multiply by your time step, getting a 1x7.
Now you add the 7x1 y0 to the 1x7. In all releases before r2016b that would be an error. In R2016b and later there is the equivalent of bsxfun, so the results of adding the two with different orientations is 7x7 which is the output size you get.
Perhaps you want to do something more like
y(end+1, :) = y(end, :) + odes().' * Delta
  1 commentaire
Dursman Mchabe
Dursman Mchabe le 9 Oct 2018
Thanks a lot for the response, I have to quickly read/learn about Pad array or interpolation.
I think I am simply failing to make my loop to repeat 30 times. I think wanted line 42 to be
y(end+1, :) = y(end, :) + odes().' * Delta
instead of
y = y0 + dydt' * Delt;
Thanks a lot once again Walter.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by