Azzera filtri
Azzera filtri

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 visualizzazione (ultimi 30 giorni)
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 Commenti
Dursman Mchabe
Dursman Mchabe il 9 Ott 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.

Accedi per commentare.

Risposta accettata

Walter Roberson
Walter Roberson il 9 Ott 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 Commento
Dursman Mchabe
Dursman Mchabe il 9 Ott 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.

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Loops and Conditional Statements in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by