フィルターのクリア

Save values in each iteration

1 回表示 (過去 30 日間)
Ricardo Gutierrez
Ricardo Gutierrez 2019 年 8 月 20 日
コメント済み: Ricardo Gutierrez 2019 年 8 月 20 日
Hello !!!
Good Morning.
I have the following code:
----------------------------------------------------------------------
clc; clear; close all; short format
Ccl = 21; % Number of column elements
gene = 5; % Number of times the column is generated
for wl = 1: gen
for kk = 1: Ccl
minx1 = 0.2028;
maxx1 = 1.0141;
xx1 = (maxx1-minx1). * rand (1,1) + minx1;
dx1 (kk) = xx1;
dx1 = dx1 ';
end
end
-------------------------------------------------- -----------------------
This code randomly generates a vector of a column with 21 lines (21 X 1), but
I would like to keep the values of the 5 columns, this case the variable "gen" has 5
Normally the value of the "gen" variable can be 500.
Greetings and thanks.

回答 (1 件)

James Tursa
James Tursa 2019 年 8 月 20 日
編集済み: James Tursa 2019 年 8 月 20 日
The loops aren't needed. E.g.,
Ccl = 21; % Number of column elements
gene = 5; % Number of times the column is generated
minx1 = 0.2028;
maxx1 = 1.0141;
dx1 = (maxx1-minx1). * rand (Ccl,gene) + minx1;
Then the syntax dx1(:,k) can be used to extract the k'th column.
  1 件のコメント
Ricardo Gutierrez
Ricardo Gutierrez 2019 年 8 月 20 日
Thank you so much !!!!
This work

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

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by