フィルターのクリア

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 回表示 (過去 30 日間)
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 件のコメント
KSSV
KSSV 2018 年 10 月 9 日
Have a look on interp1 if you are looking for interpolation.
Dursman Mchabe
Dursman Mchabe 2018 年 10 月 9 日
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.

サインインしてコメントする。

採用された回答

Walter Roberson
Walter Roberson 2018 年 10 月 9 日
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 件のコメント
Dursman Mchabe
Dursman Mchabe 2018 年 10 月 9 日
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.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by