error using mrdivide: Matrix dimensions must agree?

hi, i'm beginner using matlab. i have problem with my script:
clear all;close all;clc
%parameter
nx=301;ny=161;
dlon=0.05;dlat=0.05;
lat=-10:dlat:-2;
lon=100:dlon:115;
h=6.626068e34;
c=2.997925e8;
k=1.38e-23;
lamda=3.75e-6;
lo=2395555.55555556;
u=0.9;
%load data tbb
fid1=fopen('IR1_all.dat','rb');
for t=1:2
tmp=fread(fid1,[nx,ny],'float32');
tbb1(:,:,t)=tmp;
clear tmp
end
fid2=fopen('IR4_all.dat','rb');
for t=1:2
tmp=fread(fid2,[nx,ny],'float32');
tbb4(:,:,t)=tmp;
clear tmp;
end
rad1=(2*h*c^2)/((lamda^5)*(exp(((h*c)/(lamda*k*tbb1)))-1));
for j0=1:ny-1
for i0=1:nx-1
for t=1:2
rad1=(2.*h*c^2)/((lamda^5)*(exp(((h*c)/(lamda*k*tbb1)))-1.));
end
end
end
this is the error message:
*??? Error using ==> mrdivide Matrix dimensions must agree.
Error in ==> at 28 rad1=(2*h*c^2)/((lamda^5)*(exp(((h*c)/(lamda*k*tbb1)))-1)*
please help me

Answers (1)

You probably want to use ./ instead of /
Also you should be careful about using * vs .*
Please read the documentation for the routines named
mrdivide - the / operator
rdivide - the ./ operator
mtimes - the * operator
times - the .* operator

Asked:

on 2 Jan 2012

Community Treasure Hunt

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

Start Hunting!