Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
ERROR MESSAGE - MRDIVIDE, MATRIX DIMENSIONS MUST AGREE

Subject: ERROR MESSAGE - MRDIVIDE, MATRIX DIMENSIONS MUST AGREE

From: asri

Date: 2 Jan, 2012 06:52:08

Message: 1 of 3

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:1
    tmp=fread(fid1,[nx,ny],'float32');
    tbb1(:,:,t)=tmp;
    clear tmp
end
fid2=fopen('IR4_all.dat','rb');
for t=1:1
    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:1
           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 ==> itung_ref_coba at 28
rad1=(2*h*c^2)/((lamda^5)*(exp(((h*c)/(lamda*k*tbb1)))-1)

Subject: ERROR MESSAGE - MRDIVIDE, MATRIX DIMENSIONS MUST AGREE

From: Torsten

Date: 2 Jan, 2012 08:01:53

Message: 2 of 3

On 2 Jan., 07:52, "asri " <achi_a...@yahoo.com> wrote:
> 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:1
>     tmp=fread(fid1,[nx,ny],'float32');
>     tbb1(:,:,t)=tmp;
>     clear tmp
> end
> fid2=fopen('IR4_all.dat','rb');
> for t=1:1
>     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:1
>            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 ==> itung_ref_coba at 28
> rad1=(2*h*c^2)/((lamda^5)*(exp(((h*c)/(lamda*k*tbb1)))-1)

You mean

for j0=1:ny-1
     for i0=1:nx-1
         for t=1:1
            rad1(i0,j0,t)=(2.*h*c^2)/((lamda^5)*(exp(((h*c)/
(lamda*k*tbb1(i0,j0,t))))-1.));
         end
     end
end

or shorter

rad1=(2.*h*c^2)/((lamda^5)*(exp(((h*c)./(lamda*k*tbb1)))-1.));

??

Best wishes
Torsten.

Subject: ERROR MESSAGE - MRDIVIDE, MATRIX DIMENSIONS MUST AGREE

From: Roger Stafford

Date: 2 Jan, 2012 08:25:08

Message: 3 of 3

Torsten <Torsten.Hennig@umsicht.fraunhofer.de> wrote in message <9f098290-3bcf-4c34-b72e-be16374be252@q11g2000vbq.googlegroups.com>...
> On 2 Jan., 07:52, "asri " <achi_a...@yahoo.com> wrote:
> > rad1=(2*h*c^2)/((lamda^5)*(exp(((h*c)/(lamda*k*tbb1)))-1));
> ......
> rad1=(2.*h*c^2)/((lamda^5)*(exp(((h*c)./(lamda*k*tbb1)))-1.));
> Torsten.
- - - - - - - - - -
  You will need the dot on both divisions there:

 rad1=(2*h*c^2)./((lamda^5)*(exp(((h*c)./(lamda*k*tbb1)))-1));

  That is because the '/' symbol alone means matrix right division and in this case expects a numerator with 161 columns. This is clearly not what you want.

Roger Stafford

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us