Hi !!! Have a nice day.
I have a code that starts with the generation of a matrix A,
after a numerical process at the end I have a matrix B
A = [a, b, c,… ..
q, w, r,….];
instructions
instructions
instructions
instructions
instructions
instructions
B = [d, e, f,….
and, u, I, ...];
At the end of the numerical process I have matrix B, immediately
the values of B are assigned to A in this way
A = B
What instruction I need to do to generate this cycle N times, that this; the results of B introduce them to input A?
I hope you understand what I want to do
Thank you

댓글 수: 6

Raj
Raj 2019년 12월 5일
"cycle N times" - A for loop maybe? Try giving more clarity!
Ricardo Gutierrez
Ricardo Gutierrez 2019년 12월 5일
I already tried it with a "for" cycle but only when N = 1 the matrix A is updated with values of matrix B.
When N => 1 say N = 5 the values are repeated 4 times, it is only updated the first time.
Adam Danz
Adam Danz 2019년 12월 5일
The question is unclear. Do you want to concatenate A n-times? Horizontally or vertically?
If you provide a pair of inputs and expected outputs it may be helpful to explain the problem.
Ricardo Gutierrez
Ricardo Gutierrez 2019년 12월 5일
No, I don't want to concatenate. I want to update the values of A with the resulting matrix B, in each cycle(n times). But this I have not been able to achieve.
Adam Danz
Adam Danz 2019년 12월 5일
편집: Adam Danz 2019년 12월 5일
" I want to update the values of A with the resulting matrix B"
So you want to completely overwrite A with whatever is stored in B on each iteration.
But this I have not been able to achieve"
Why not? What specific problems have you faced?
Again, a simple example of expected input and outputs usually saves quite a bit of time and dialog.
Ricardo Gutierrez
Ricardo Gutierrez 2019년 12월 5일
You are right.
I should check my code.
Thank you very much for your patience and your help.

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

 채택된 답변

meghannmarie
meghannmarie 2019년 12월 5일

0 개 추천

Can you show your code? Make sure you are initally setting A before the for loop. If I am understanding the problem, it should look something like this:
A = [a,b,c;q,w,r];
for n = 1:5
% instructions
% instructions
% instructions
B = [d,e,f;l,m,n]
A = B;
end

댓글 수: 5

Ricardo Gutierrez
Ricardo Gutierrez 2019년 12월 5일
Hello good day
Thanks for your attention
Yes, this is the structure of the code as you show it.
Matrix A updates me only in the first cycle, but in subsequent cycles it repeats the first update.
The code I am working on has 210 lines is very extensive
If you expect to vertically concatenate A,
B = [d,e,f;l,m,n]
A = [A;B];
If you expect to horizontally concatenate A,
B = [d,e,f;l,m,n]
A = [A,B];
Ricardo Gutierrez
Ricardo Gutierrez 2019년 12월 5일
No, I don't want to concatenate. I want to update the values of A with the resulting matrix B, in each cycle. But this I have not been able to achieve.
meghannmarie
meghannmarie 2019년 12월 5일
Is variable A part of the input into building variable B? There must be an error in your code, I do not know how to troubleshoot without code.
Ricardo Gutierrez
Ricardo Gutierrez 2019년 12월 5일
Thank you very much.
You are right there must be some error in my code.
Thank you for your patience and attention.

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

제품

릴리스

R2014a

Community Treasure Hunt

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

Start Hunting!

Translated by