how to save the output of For loop in a matrix form!

1 回表示 (過去 30 日間)
praneeth pasari
praneeth pasari 2017 年 4 月 7 日
編集済み: Stephen23 2017 年 4 月 10 日
hello I have a sample size of 191X6. I wrote a for loop for the sample as "s = sample(:,1:6)", applied few functions in the loop like
anom = abs(s - mean(s));
[~,idx] = max(anom);
lambdaHa = lambda(idx);
z = lambdaHa/656.28 - 1;
speed = z*300000;
I want to save the output of each iteration of the loop and save the value of the speed, which should be 6X1 matrix. thanks in advance.

回答 (1 件)

Thorsten
Thorsten 2017 年 4 月 7 日
編集済み: Thorsten 2017 年 4 月 10 日
for i = 1:size(sample, 2)
s = sample(:, i); % extract only the i'th column!
% your code:
anom = abs(s - mean(s));
[~,idx] = max(anom);
lambdaHa = lambda(idx);
z = lambdaHa/656.28 - 1;
speed(i) = z*300000;
end

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

タグ

タグが未入力です。

製品

Community Treasure Hunt

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

Start Hunting!

Translated by