Looping over a double

4 ビュー (過去 30 日間)
Marcos Perez Rodriguez
Marcos Perez Rodriguez 2020 年 3 月 4 日
I have a double with 2808 time values stored in it. I want to loop it over a function where every iteration the time changes to the next time minus the first.. nth time minus the first time.
This is the eq: 1/(j+1) where j is the time value that would change every iteration and store value, index.
This is what I currently have:
time = a double with 2808 time values
for i = 1:size(time)
a(i) = i-7.3457e+05; %a is double storing time since mainshock
end
for j = 0:size(a)
aa(j+1) = 1/(j+1); %this is the eq I want to implement
end

採用された回答

David Hill
David Hill 2020 年 3 月 4 日
I think this is what you are asking for.
time=time-time(1);
aa=1./time;
  1 件のコメント
Marcos Perez Rodriguez
Marcos Perez Rodriguez 2020 年 3 月 4 日
Yes! Thank you!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

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