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

8 views (last 30 days)
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

Answers (1)

KALYAN ACHARJYA
KALYAN ACHARJYA on 3 Apr 2020
Edited: KALYAN ACHARJYA on 3 Apr 2020
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

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!