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!!

 채택된 답변

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

질문:

2020년 3월 5일

댓글:

2020년 3월 5일

Community Treasure Hunt

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

Start Hunting!

Translated by