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:
A(I)=B

Subject: A(I)=B

From: Gule Saman

Date: 16 Mar, 2009 18:20:03

Message: 1 of 8

??? In an assignment A(I) = B, the number of elements in B and
 I must be the same.

Error in ==> calculate_polt_sin at 3
A(1)=mean(intensity);

Error in ==> plotsin at 6
[A,y,standard_deviation,maxerror,minerror]=calculate_polt_sin(polang,intensity,h);

Error in ==> file_reading_plotting_pol_angle at 101
S=plotsin(polang,intensity,h);


can anyone help me with this?

Subject: A(I)=B

From: us

Date: 16 Mar, 2009 18:33:02

Message: 2 of 8

"Gule Saman"
> ??? In an assignment A(I) = B, the number of elements in B and
> I must be the same.
> Error in ==> calculate_polt_sin at 3
> A(1)=mean(intensity);
> Error in ==> plotsin at 6
> [A,y,standard_deviation,maxerror,minerror]=calculate_polt_sin(polang,intensity,h);
> Error in ==> file_reading_plotting_pol_angle at 101
> S=plotsin(polang,intensity,h);
> can anyone help me with this...

well, YES, the error message is pretty clear - is it not?...
- the number of (true!) elements of I
- is not equal to the number of elements of B
how do you check...

% at the command prompt, type
     dbstop if error;
% run your code
% it will stop and open the file in the editor at the offending line
% now
     whos I B
% if I is of class logical, also do
     nnz(I)

us

Subject: A(I)=B

From: Vince Petaccio

Date: 16 Mar, 2009 18:37:00

Message: 3 of 8

A(1)=mean(intensity);
What your command here is saying is that the first value of A should be the mean of your data, intensity.

The error message that you're getting is saying that you're trying to assign more than one value to A(1).

Common sense dictates that the "mean" value is a single value. In MATLAB, though, if intensity is a multi-dimensional cell or vector, you will get more than one value from the "mean" function- one for each ROW.

Try this:

test = zeros(2,2); %Create a 2x2 vector of zeros
testmean = mean(test); %Get the mean value of that vector

testmean = [0,0];
%Your answer is returned as a vector, with a "mean" value for each row in your original vector.

Make sure that your intensity vector is being formed correctly. If so, try making a single vector, containing the values from each row of intensity, and then taking the mean value of that. Or, you can take a "mean of means" by getting the mean value for each of the rows in intensity, then taking the mean of those.

-Vince

Subject: A(I)=B

From: Gule Saman

Date: 16 Mar, 2009 19:12:03

Message: 4 of 8

i have tried this but it gives the same error again. I have ten intensity values that i pass into this function to find the mean.

"Vince Petaccio" <vince@moberg.com> wrote in message <gpm68c$a93$1@fred.mathworks.com>...
> A(1)=mean(intensity);
> What your command here is saying is that the first value of A should be the mean of your data, intensity.
>
> The error message that you're getting is saying that you're trying to assign more than one value to A(1).
>
> Common sense dictates that the "mean" value is a single value. In MATLAB, though, if intensity is a multi-dimensional cell or vector, you will get more than one value from the "mean" function- one for each ROW.
>
> Try this:
>
> test = zeros(2,2); %Create a 2x2 vector of zeros
> testmean = mean(test); %Get the mean value of that vector
>
> testmean = [0,0];
> %Your answer is returned as a vector, with a "mean" value for each row in your original vector.
>
> Make sure that your intensity vector is being formed correctly. If so, try making a single vector, containing the values from each row of intensity, and then taking the mean value of that. Or, you can take a "mean of means" by getting the mean value for each of the rows in intensity, then taking the mean of those.
>
> -Vince

Subject: A(I)=B

From: someone

Date: 16 Mar, 2009 20:08:01

Message: 5 of 8

"Gule Saman" <gulesaman@gmail.com> wrote in message <gpm8a3$2nr$1@fred.mathworks.com>...
> i have tried this but it gives the same error again. I have ten intensity values that i pass into this function to find the mean.

% What did you try? Its not clear what "this" is.

% If intensity is an array (or vector) of ten values, then

mean(intensity(:));

% should return a scalar that is the average of those ten values
% regardless of the size of intensity.
% Is that what you want?

>
> "Vince Petaccio" <vince@moberg.com> wrote in message <gpm68c$a93$1@fred.mathworks.com>...
> > A(1)=mean(intensity);
> > What your command here is saying is that the first value of A should be the mean of your data, intensity.
> >
> > The error message that you're getting is saying that you're trying to assign more than one value to A(1).
> >
> > Common sense dictates that the "mean" value is a single value. In MATLAB, though, if intensity is a multi-dimensional cell or vector, you will get more than one value from the "mean" function- one for each ROW.
> >
> > Try this:
> >
> > test = zeros(2,2); %Create a 2x2 vector of zeros
> > testmean = mean(test); %Get the mean value of that vector
> >
> > testmean = [0,0];
> > %Your answer is returned as a vector, with a "mean" value for each row in your original vector.
> >
> > Make sure that your intensity vector is being formed correctly. If so, try making a single vector, containing the values from each row of intensity, and then taking the mean value of that. Or, you can take a "mean of means" by getting the mean value for each of the rows in intensity, then taking the mean of those.
> >
> > -Vince

Subject: A(I)=B

From: us

Date: 16 Mar, 2009 20:49:01

Message: 6 of 8

"Gule Saman"
> i have tried this but it gives the same error again. I have ten intensity values that i pass into this function to find the mean...

why do you not simply start with the DEBUG-stuff that was shown to you...

us

Subject: A(I)=B

From: Gule Saman

Date: 17 Mar, 2009 13:00:18

Message: 7 of 8

yes i think... thank u :)
"someone" <someone@somewhere.net> wrote in message <gpmbj1$kc5$1@fred.mathworks.com>...
> "Gule Saman" <gulesaman@gmail.com> wrote in message <gpm8a3$2nr$1@fred.mathworks.com>...
> > i have tried this but it gives the same error again. I have ten intensity values that i pass into this function to find the mean.
>
> % What did you try? Its not clear what "this" is.
>
> % If intensity is an array (or vector) of ten values, then
>
> mean(intensity(:));
>
> % should return a scalar that is the average of those ten values
> % regardless of the size of intensity.
> % Is that what you want?
>
> >
> > "Vince Petaccio" <vince@moberg.com> wrote in message <gpm68c$a93$1@fred.mathworks.com>...
> > > A(1)=mean(intensity);
> > > What your command here is saying is that the first value of A should be the mean of your data, intensity.
> > >
> > > The error message that you're getting is saying that you're trying to assign more than one value to A(1).
> > >
> > > Common sense dictates that the "mean" value is a single value. In MATLAB, though, if intensity is a multi-dimensional cell or vector, you will get more than one value from the "mean" function- one for each ROW.
> > >
> > > Try this:
> > >
> > > test = zeros(2,2); %Create a 2x2 vector of zeros
> > > testmean = mean(test); %Get the mean value of that vector
> > >
> > > testmean = [0,0];
> > > %Your answer is returned as a vector, with a "mean" value for each row in your original vector.
> > >
> > > Make sure that your intensity vector is being formed correctly. If so, try making a single vector, containing the values from each row of intensity, and then taking the mean value of that. Or, you can take a "mean of means" by getting the mean value for each of the rows in intensity, then taking the mean of those.
> > >
> > > -Vince

Subject: A(I)=B

From: Gule Saman

Date: 17 Mar, 2009 13:01:03

Message: 8 of 8

yes i know where the problem lies... i have done debugging
"us " <us@neurol.unizh.ch> wrote in message <gpmdvt$6cl$1@fred.mathworks.com>...
> "Gule Saman"
> > i have tried this but it gives the same error again. I have ten intensity values that i pass into this function to find the mean...
>
> why do you not simply start with the DEBUG-stuff that was shown to you...
>
> us

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