How can i do a loop function

1 回表示 (過去 30 日間)
Merel Vanderweeën
Merel Vanderweeën 2021 年 4 月 29 日
回答済み: Nagasai Bharat 2021 年 5 月 3 日
Hi!
I would like to calculate the net present value of a number per 60 years. So i have matrix 100x60 matrix (BuildingEnvelope_LCA_input), where there is the price of something in the rows, and then the price per year in the columns. So i would have to go by every number of the matrix, and do a calculation. This is how it looks in excel:
I thought it would be possible by a loop or something, but i am a matlab beginner and have no idea. I thought it would be something like this:
for n=1:10
BuildingEnvelope_LCA_input[:,n]/(1+0.018)^n
end
Is this correct? Or what should i do?

回答 (1 件)

Nagasai Bharat
Nagasai Bharat 2021 年 5 月 3 日
Hi,
From my understanding you are trying to apply an operation to every element in you array. The arrayfun function should help you achive that instead of using a loop.

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by