필터 지우기
필터 지우기

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.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Import, Export, and Conversion에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by