How to use a loop to increase polynomial order and store results

조회 수: 8 (최근 30일)
Leia George
Leia George 2020년 4월 3일
편집: KALYAN ACHARJYA 2020년 4월 3일
Hi, sorry if this is not very clear, I am not confident with code at all.
I am attempting to fit polynomials to messy, scattered data in matlab. I need to evalute which polynomial order is best for each dataset. I am happy with how to statistically evaluate this for each polynomial size but I would like to set up a loop so I don't need to execute each one individually.
I would like to execute
for
T0 = horzcat((t^0));
execute some calculations, resulting in e.g. R2 = 0.45, AR2 = 0.4
T1 = horzcat((t^0), (t^1));
execute the calculations
T2 = horzcat((t^0), (t^1), (t^2));
execute the calculations
Up to around T9, each time storing the two resultant values in some way, can someone please advise a way that I can do this?
(I do have working code for the calculations if that would be helpful)
Thank you

답변 (1개)

KALYAN ACHARJYA
KALYAN ACHARJYA 2020년 4월 3일
편집: KALYAN ACHARJYA 2020년 4월 3일
One way hints: Start with T(1) to T(10), Matlab doesnot allow zero indexing
T(1)=t^1
for i=2:9
T(i)=[T(i-1),t^i];
end

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by