필터 지우기
필터 지우기

print value to matrix

조회 수: 2 (최근 30일)
Esra Demirbilek
Esra Demirbilek 2022년 5월 28일
답변: Voss 2022년 5월 28일
Hello everyone,
I have a code.In this code, there are V values ​​consisting of 20 rows as a result of each iteration.What I want to do: I want to see the v values ​​formed in each iteration in the same matrix. How can I do it?
for example;
iteration:1
V=
10
5
1
....
iteration:2
V=
15
4
2
....
V_new;
iteration 1 2 3 4 ....
10 15 20 10
5 4 3 2
1 2 3 8
thanks advance

답변 (2개)

dpb
dpb 2022년 5월 28일
nIter=YourNumberOfTotalIterations;
nRows=20;
V=zeros(nRows,nIter); % preallocate
for i=1:nIter
V(:,i)=YourFunctionCreatingVector(...);
end

Voss
Voss 2022년 5월 28일
V_new = [];
for ii = 1:max_iterations
% calculate V
V_new(:,ii) = V;
end
Also, if you know ahead of time how many iterations there will be, you can preallocate V_new to be the appropriate size before the loop:
V_new = zeros(20,max_iterations);

카테고리

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

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by