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:
Beginners help

Subject: Beginners help

From: Maria

Date: 20 Aug, 2008 08:23:02

Message: 1 of 4

I'm a beginner in matlab. & I'm trying to use the following
function, and this error comes up:
Error: File: calculateSEL.m Line: 18 Column: 5
 "std" previously appeared to be used as a function or
 command, conflicting with its use here as the name of a
 variable.
 A possible cause of this error is that you forgot to
 initialize the
 variable, or you have initialized it implicitly using load
 or eval.

Can anyone help me?THANKS


function method_error=calculateSEL(x,r,name);

%x - replicate measurements
%r - number of replicate measurements
%name - name of the component which was measured
%SEL - standard error of laboratory
%mRSD - mean Relative Standard Deviation

n=size(x,1)/r;
figure
hold
title(name,'FontSize',16,'FontWeight','bold')

for i=1:n
    reps=x(3*i-2:3*i,:);
    %calculates the average for each sample
    m(i)=mean(reps);
    std(i)=std(reps);
    for j=1:r
        %calculates the difference between the average and
each replicate
        d(j)=reps(j)-m(i);
    end
    %calculates the sum of the square for each sample
    d2(i)=d*d';
    
    %calculates RSD
    s(i)=sqrt(d2(i)/(r-1));
    RSD(i)=s(i)/m(i)*100;
    
    plot(i,reps/m(i),'ok')
    hline(1,'r')
    xlabel('Sample number','FontSize',14)
    ylabel(['y_m_e_a_s_u_r_e_d / mean of ' num2str(r) '
replicates'],'FontSize',14)
    
    
end

%calculates SEL
SEL=sqrt(sum(d2)/(n*(r-1)));

%calculates RSD mean
mRSD=mean(RSD);
medianRSD=median(RSD);


%calculates standard deviation
mstd=mean(std);

method_error.SEL=SEL;
method_error.mRSD=mRSD;
method_error.RSD=RSD;
method_error.mstd=mstd;
method_error.means=m;
method_error.stds=std;



%to see if there any sample with RSD too different
figure
plot(RSD,'o')
xlabel('Sample number')
ylabel('Relative Standard Deviation (%)')
title(name,'FontSize',16,'FontWeight','bold')


disp(' ')
disp(name)
disp(['No amostras usadas = ' num2str(n) ])
disp(['SEL = ' num2str(SEL)])
disp(['mean RSD = ' num2str(mRSD)])
disp(['median RSD = ' num2str(medianRSD)])
disp(['mean standard deviation = ' num2str(mstd)])



disp(' ')
disp(' ')
disp(' ')

Subject: Beginners help

From: rodney.thomson@gmail.com

Date: 20 Aug, 2008 08:37:21

Message: 2 of 4

> std(i)=std(reps);

Theres your problem. You cant treat std as a variable and a function
at the same time.

Call it something else:

> standard_deviation(i) = std(reps)

Rod

http://iheartmatlab.blogspot.com

Subject: Beginners help

From: Maria

Date: 20 Aug, 2008 12:25:04

Message: 3 of 4

Hi Rod
thanks for your help!
I had already changed to another name, but now this message
appears:
In an assignment A(I) = B, the number of elements in B and
 I must be the same.

Error in ==> calculateSEL at 17
    m(i)=mean(reps);

Any suggestions?!
Thanks again!
mariana

rodney.thomson@gmail.com wrote in message
<214f55fd-a5c7-4607-8cfb-7657260c84c9@v13g2000pro.googlegroups.com>...
> > std(i)=std(reps);
>
> Theres your problem. You cant treat std as a variable and
a function
> at the same time.
>
> Call it something else:
>
> > standard_deviation(i) = std(reps)
>
> Rod
>
> http://iheartmatlab.blogspot.com

Subject: Beginners help

From: Adam

Date: 20 Aug, 2008 13:02:03

Message: 4 of 4

"Maria " <m.fazenda@strath.ac.uk> wrote in message
<g8h2f0$na5$1@fred.mathworks.com>...
> Hi Rod
> thanks for your help!
> I had already changed to another name, but now this message
> appears:
> In an assignment A(I) = B, the number of elements in B and
> I must be the same.
>
> Error in ==> calculateSEL at 17
> m(i)=mean(reps);
>
> Any suggestions?!
> Thanks again!
> mariana
>

reps is a matrix? It takes the mean down each column.

mean(reps(:))

another possibility is i is a vector, then it needs to be
the same size as whatever mean(reps) returns (check on the
command line).

~Adam

Tags for this Thread

No tags are associated with 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