Computational problem

2 ビュー (過去 30 日間)
Nello Troccia
Nello Troccia 2012 年 3 月 27 日
Hi, this simple code gives a matrix.
n=6;
m=5;
for p=2:1:(n-1)
cc=(2+(m*(p-1))):1:(m*p-1)
end
in the command window it returns the values: 7,8,9,12,13,14,17,18,19,22,23,24; but in the workspace it save a matrix of three elements: 22,23,24. How could I do to have a matrix of all element? (if is possible without for) Regards

採用された回答

Andrei Bobrov
Andrei Bobrov 2012 年 3 月 27 日
n=6;
m=5;
p = 2:(n-1);
for j1 = numel(p):-1:1
cc(:,j1) = (2+(m*(p(j1)-1))):1:(m*p(j1)-1);
end
cc = cc(:).'
  1 件のコメント
Nello Troccia
Nello Troccia 2012 年 3 月 27 日
thanks a lot

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by