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 ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by