Array manipulation with loop

Hello, I have a question about array manipulation:
Having an array A=[1;2;3;4;5;6] What is a simple way to update the array A so that when it loops, array A becomes: A=[2;3;4;5;6;7] for N times!
The element 7 is calculated from the first 6 elements and the values in the column are to be shifted upwards and the new value is to be replaced with the last value of previous array, for N number of times;
All help is very much appreciated, Thank you in advance!

 채택된 답변

Sean de Wolski
Sean de Wolski 2012년 5월 25일

0 개 추천

A+N

댓글 수: 1

Behnaz
Behnaz 2012년 5월 25일
Thanks for the quick response Sean, it worked like a charm.
I was also wondering how I could store all the values of A in another array so it is not limited to 6 (the example);
I'm trying to predict the next value of A for a set of data and compare to my original values and find the error!
Time=[0.015;0.03;0.045;0.06;0.075;0.09;0.105];
A=[17;18.5;20.35;22.4;22.68;23.55;24.1];
for i=1:200
T_i=Time + 0.015;
xfit = linspace(0,0.2,50);
coeffs5 = polyfit(Time, A, 5);
new_A=polyval(coeffs5,T_i);
end
Thanks alot!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by