Borrar filtros
Borrar filtros

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

2 visualizaciones (últimos 30 días)
Anson Hancock
Anson Hancock el 8 de Sept. de 2014
Comentada: Anson Hancock el 9 de Sept. de 2014
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.

Respuesta aceptada

Iain
Iain el 8 de Sept. de 2014
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.

Más respuestas (0)

Categorías

Más información sobre Import, Export, and Conversion en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by