フィルターのクリア

Using all values in a matrix as inputs for a function.

2 ビュー (過去 30 日間)
Anson Hancock
Anson Hancock 2014 年 9 月 8 日
コメント済み: Anson Hancock 2014 年 9 月 9 日
I am new to Matlab and programming and am hoping that someone can help me out or point me in the right direction with an issue I have run into.
I have a 240x320 matrix (tempK) derived from a thermal image. Each cell in the matrix contains the temperature value of the cosponsoring pixel from the thermal image. I have defined the following function:
function out=Planck_radconvers(lambda_,tempK)
C1 = 1.19e-16;
C2 = 1.44e-2;
out=C1/(lambda_^5*(exp(C2/(lambda_*tempK))-1))*1e-6;
end
I then tried to use this function by applying the following:
rad=planck(10.25e-6,tempK)
The issue is that I have only been able to figure out how to get "rad" to out put the result for a single cell in "tempK". However I need it to do this for every cell in "tempK" and I need the output of "rad" to be the same dimensions as "tempK" (i.e. I need each all the converted values from "tempK" to have the same cell locations in "rad").
Any help on this would be very much appreciated.

採用された回答

Iain
Iain 2014 年 9 月 8 日
You need to distinguish the fact that matlab, by default, does matrix multiplication, division and powers by the actual matrix multiplication rules.
You simply need to tell it not to do actual matrix multiplications etc, but to do element-wise multiplications etc.
Replace * with .*, / with .* and ^ with .^, and you shouldn't have a problem.
  1 件のコメント
Anson Hancock
Anson Hancock 2014 年 9 月 9 日
Thanks for that Iain, it totally did the trick.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeImport, Export, and Conversion についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by