Save the answer as an array

Hi, may I ask how can I save the output MT as an array that has all the 19 values?
The code is as follows:
for y = 1.5 : 19.5
[MT, MN] = WTSingleVelocity(20, 0.209, -0.00698, 1, 0, y, 3.1416, 3);
disp(MT)
end
I've tried MT1 = zeros(20,1) and MT1 (y)= MT, but the indices are not integer so it is not working.
Thank you!

2 件のコメント

Geoff Hayes
Geoff Hayes 2019 年 10 月 24 日
Jiaqi - is WTSingleVelocity code (of yours) that you can modify so that you can pass in an array (instead of scalars for y) and then get returned your MT array? If you can't modify the code to do this, then just use a different parameter for the index into MT1. For example,
k = 1;
MT1 = zeros(20,1)
for y = 1.5:19.5
[MT, MN] = WTSingleVelocity(20, 0.209, -0.00698, 1, 0, y, 3.1416, 3);
disp(MT)
MT1(k) = MT;
k = k + 1;
end
Jiaqi Dong
Jiaqi Dong 2019 年 10 月 24 日
Geoff, thank you very much!
This is exactly what I am looking for. I was trying to find a way that does not modify the WT code.
:)

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

回答 (0 件)

カテゴリ

製品

質問済み:

2019 年 10 月 24 日

コメント済み:

2019 年 10 月 24 日

Community Treasure Hunt

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

Start Hunting!

Translated by