フィルターのクリア

Quick for loop output question?

2 ビュー (過去 30 日間)
Tom
Tom 2013 年 4 月 25 日
I have a for loop saying J = 9000000:18000000
....commands.....
Before end I have R(J) = [equation];
R is my output matrix. Keep in mind I am dealing with large numbers.
Instead of starting the first matrix cell with 9 million, it writes 8,999,999 zero-valued cells before getting to what I want. I am kind of fresh to this, so how might I start writing the output at the very first cell with 9,000,000?
  1 件のコメント
Matt Kindig
Matt Kindig 2013 年 4 月 25 日
What you are doing really can't be done by Matlab, as it automatically "fills" the missing matrix elements with zeros. Unfortunately, I can't really see a way to get around this.

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

回答 (1 件)

Walter Roberson
Walter Roberson 2013 年 4 月 25 日
R(J-9000000+1) = ....
I write it in that form as part of making the coding clearer:
lowJ = 9000000;
highJ = 18000000;
R = zeros(highJ - lowJ + 1,1);
for K = lowJ : highJ
R(K = lowJ + 1) = ....
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