Hi everyone,
I have a bunch of calculations like this:
F1 = (H(4,1) - baseline1) / baseline1
F2 = (H(20,1) - baseline2) / baseline2
F3 = (H(36,1) - baseline3) / baseline3
...
F20 = (H(308,1) - baseline20) / baseline20
As you can see, the row in H goes up in an increment of 16. I thought a loop may be good for this but am unsure how to go about it. Does anyone have any suggestions?
Thanks,
Le

5 件のコメント

Star Strider
Star Strider 2014 年 4 月 8 日
What is baseline?
Scalar?
Vector? What are its dimensions?
Thang  Le
Thang Le 2014 年 4 月 8 日
Baseline is 1x1 double. It's a number I calculated from a preivous step.
Star Strider
Star Strider 2014 年 4 月 8 日
Are you storing baseline1 and the rest, or are they one-offs?
I ask because you could as easily store them as baseline(1), etc. That would make it much easier for you to reference them in a loop.
Is H a vector (308x1) or matrix?
(I’m doing my best to figure out what you are doing.)
Thang  Le
Thang Le 2014 年 4 月 8 日
I'm sorry my question wasn't clear. I'm not storing baselines. The baselines are just intermediate values that are calculated prior to this. H is a matrix. In this case it's 308x1 but I can see it being 308x8 once I adapt the script to run on multiple region of interests.
Image Analyst
Image Analyst 2014 年 4 月 8 日
OK, I've modified my answer code to take this new information into account.

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

 採用された回答

Image Analyst
Image Analyst 2014 年 4 月 8 日
編集済み: Image Analyst 2014 年 4 月 8 日

0 投票

You can't really have a loop because all your baseline variable have a different name. (Well actually you can but no one wants to show you how because it's not recommended). See the FAQ: http://matlab.wikia.com/wiki/FAQ#How_can_I_create_variables_A1.2C_A2.2C....2CA10_in_a_loop.3F
That's why we won't tell you how to make F1, F2, F3, etc. If you want to have F be an array and baseline be an array, then that's normal, and you can use a loop and we will tell you how to do that:
for k = 1 : 20
hIndex = 4 + (k-1)*16;
baseline = whatever; % Not sure how you calculate this.
F(k) = (H(hIndex,1) - baseline) / baseline;
end
Though I don't know why you want the row index of H to go like that.

1 件のコメント

Thang  Le
Thang Le 2014 年 4 月 8 日
Thank you, Image Analyst! I appreciate your (and everyone's) being patient with me. I'm quite new to working with Matlab as you can tell.

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File Exchange で Loops and Conditional Statements についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by