Printing and Plotting after each loop

2 Ansichten (letzte 30 Tage)
A
A am 3 Mär. 2021
Kommentiert: A am 6 Mär. 2021
I have a for loop where the structure is like this
A=[1 3 4;3 5 6]
U=[]
for i=1:10
...
U=A
end
how would I print U matirx after each loop on the text file beacause when I am doing that only the matirx in the 10th iteration loop prints and how would I be able to plot all those iterations in one figure using point clouds?
  3 Kommentare
Michael
Michael am 3 Mär. 2021
Do you want it to print to a file or the command window?
A
A am 3 Mär. 2021
I want to print it to a text file

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 4 Mär. 2021
A=[1 3 4;3 5 6]
A = 2×3
1 3 4 3 5 6
U=[]
U = []
for i=1:10
A = A * 2;
U=A;
dlmwrite('U.txt', U, '-append')
end
!cat U.txt
2,6,8 6,10,12 4,12,16 12,20,24 8,24,32 24,40,48 16,48,64 48,80,96 32,96,128 96,160,192 64,192,256 192,320,384 128,384,512 384,640,768 256,768,1024 768,1280,1536 512,1536,2048 1536,2560,3072 1024,3072,4096 3072,5120,6144
  3 Kommentare
Walter Roberson
Walter Roberson am 4 Mär. 2021
A=[1 3 4;3 5 6]
A = 2×3
1 3 4 3 5 6
U=[]
U = []
for i=1:10
A = A * 2;
U=A;
dlmwrite('U.txt', U, '-append')
dlmwrite('U.txt', ' ', '-append')
end
!cat U.txt
2,6,8 6,10,12 4,12,16 12,20,24 8,24,32 24,40,48 16,48,64 48,80,96 32,96,128 96,160,192 64,192,256 192,320,384 128,384,512 384,640,768 256,768,1024 768,1280,1536 512,1536,2048 1536,2560,3072 1024,3072,4096 3072,5120,6144
A
A am 6 Mär. 2021
Thanks Alot!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by