Hello,
I am trying to make a matrix in MATLAB that does this:
for i=1:1:400
M(i,1)=1;
M(i,2)=i;
M(i,3)=i.^2;
M(i,4)=cos(2*pi*t(i)/T+(i*pi/180));
end
But in one line.
Tried quite some things but they just wouldn't work.
Your help is much appreciated!
Cheers!!

1 件のコメント

darova
darova 2020 年 3 月 5 日
Make one row less

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

 採用された回答

Star Strider
Star Strider 2020 年 3 月 5 日

0 投票

Using 4 (rather than 400):
T = 42;
ii = (1:4).'; % Note: Transpose
t = linspace(0, 42, numel(ii)).'; % Note: Transpose
M = [ones(size(ii)), ii, ii.^2, cos(2*pi*t/T+(ii*pi/180))];

2 件のコメント

Farhan
Farhan 2020 年 3 月 5 日
Thanks!
Star Strider
Star Strider 2020 年 3 月 5 日
As always, my pleasure!

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File Exchange で MATLAB についてさらに検索

製品

リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by