Get a matrix by interaction

조회 수: 1 (최근 30일)
Ricardo Gutierrez
Ricardo Gutierrez 2019년 8월 21일
댓글: Ricardo Gutierrez 2019년 8월 22일
Hello good day.
A synthesis of the code or pseudocode is shown.
____________________________________
clc; clear; close all; short format
Ccl = 21; % Number of lines
gen = 1; % Number of times the code is repeated in each generation (gen)
for wl = 1: gen
for kk = 1: Ccl
PROCESS
Obtaining the values of:
dx1, dy1, dx2, dy2, dx3, dy3, SLL
end
BCG = horzcat (dx1, dy1, dx2, dy2, dx3, dy3, SLL);
[minimum, row] = min (BCG (:, end));
generate = BCG (row, 1: end-1)
m (wl) = minimum
end
_________________________________________________________
In the result I get a matrix ("BCG") of size 21 X 7 With the variable "gen = 1"
Giving the value of 3 to the variable "gen" gives me a matrix ("BCG") of 21 X 21
that is to say it shows me a matrix with 3 times each of the variables
What do I have to do to obtain a matrix ("BCG") of 21 X 7 in each generation (gen) and that in each generation (gen) the corresponding matrix ("BCG") is saved?
Greetings.

채택된 답변

James Tursa
James Tursa 2019년 8월 21일
Maybe use cell arrays. E.g.,
BCG{gen} = horzcat (dx1, dy1, dx2, dy2, dx3, dy3, SLL);
Then everywhere downstream in your code, use BCG{gen} to get at the underlying matrix. E.g.,
[minimum, row] = min (BCG{gen}(:, end));
generate = BCG{gen}(row, 1: end-1)
  댓글 수: 1
Ricardo Gutierrez
Ricardo Gutierrez 2019년 8월 22일
Excelent !!!
Thank you

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Assembly에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by