フィルターのクリア

how to find the square of the number

17 ビュー (過去 30 日間)
johnson saldanha
johnson saldanha 2018 年 12 月 13 日
コメント済み: johnson saldanha 2018 年 12 月 13 日
i have a matrix x where x(:,3)=[ 2 3 4 5 6];
i want the output as y(:,1)=[ 6 16 40 96 ];
input and output should be column vectors. ignoring the first element of input. i want the input to be multiplied with the (row number)^i. where i=1:length(x-1)
the code i tried is below
y=[];
for i=1:(size(x)-1)
y(i,1)= i^2*(x(2:length(x),3));
end
im getting the error as dimensions mistached, could u help me out

採用された回答

per isakson
per isakson 2018 年 12 月 13 日
編集済み: per isakson 2018 年 12 月 13 日
This produces something that is close to the result you want
%%
x(:,3)=[2;3;4;5;6];
len = size(x,1);
y = nan( len-1, 1 );
for ii = 1:len-1
y(ii,1)= ii^2*x(ii+1,3);
end
Obviously, I'm missing something in your description
  1 件のコメント
johnson saldanha
johnson saldanha 2018 年 12 月 13 日
thank you. it works fine

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by