how to form the code for fixed value and variable value

8 ビュー (過去 30 日間)
Prabha Kumaresan
Prabha Kumaresan 2017 年 11 月 30 日
コメント済み: per isakson 2017 年 11 月 30 日
the code which i need help:
i=1:10;
j=1:20,1:40,1:60,1:80,1:100,1:120;
G(i,j);
Code:
siz = size(G);
idx = sub2ind(siz, randi([1,10], 1, siz(2)), 1:siz(2));
C = zeros(siz);
C(idx) = G(idx);
in the above code the value of i=1:10,j=1:20. how to modify the code such that when the code runs second time i=1:10 and j=1:40,when the code runs for the next time i=1:10 and j=1:60 and it goes on.
  4 件のコメント
Prabha Kumaresan
Prabha Kumaresan 2017 年 11 月 30 日
i havent received any answers for the above asked questions.
per isakson
per isakson 2017 年 11 月 30 日
Tip: Use the Help and learn how to make code readable. This time I clicked the {}Code button.

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

回答 (1 件)

Walter Roberson
Walter Roberson 2017 年 11 月 30 日
persistent number_times_run
if isempty(number_times_run); number_times_run = 0; end
number_times_run = number_times_run + 1;
i = 1:10;
j = 1 : 20 * number_times_run;

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by