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:
how do i overcome the mtimes error on this input

Subject: how do i overcome the mtimes error on this input

From: raaj kumar

Date: 9 Nov, 2010 14:23:04

Message: 1 of 6

>> r = 1 - exp (-kp*n*p.^a)

n = [0:1:10]; p = [0:10:650]; a =2.8; kp = 4.14E-8

it keeps coming up with the mtimes error, what am i writing wrong here guys?

im a newbie to this programme so please take it easy on me if the mistake is really obvious :S

Subject: how do i overcome the mtimes error on this input

From: Steven_Lord

Date: 9 Nov, 2010 14:43:39

Message: 2 of 6



"raaj kumar" <tambalan30@yahoo.co.uk> wrote in message
news:ibblg8$ffd$1@fred.mathworks.com...
>>> r = 1 - exp (-kp*n*p.^a)
>
> n = [0:1:10]; p = [0:10:650]; a =2.8; kp = 4.14E-8
>
> it keeps coming up with the mtimes error, what am i writing wrong here
> guys?
>
> im a newbie to this programme so please take it easy on me if the mistake
> is really obvious :S

* is MATRIX multiplication.
.* is ELEMENTWISE multiplication (note the leading period.)

In this case, neither will work as the number of columns in n is not the
same as the number of rows in p, nor are they the same size.

What are you looking to compute with this expression? Are you looking for a
numel(n)-by-numel(p) array [or that array's transpose?]

Please respond _on the newsgroup_.

--
Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Subject: how do i overcome the mtimes error on this input

From: Sean

Date: 9 Nov, 2010 14:44:04

Message: 3 of 6

"raaj kumar" <tambalan30@yahoo.co.uk> wrote in message <ibblg8$ffd$1@fred.mathworks.com>...
> >> r = 1 - exp (-kp*n*p.^a)
>
> n = [0:1:10]; p = [0:10:650]; a =2.8; kp = 4.14E-8
>
> it keeps coming up with the mtimes error, what am i writing wrong here guys?
>
> im a newbie to this programme so please take it easy on me if the mistake is really obvious :S

Hi Raaj,

type
whos
at the command line.

You'll see that n is 1x11 and p is 1x66. For a matrix multiplication to work the inner to dimensions in this case (n*p), the 2nd dimension of n and first of p must be the same. Make sure it's what you want, as far as a result, but I think you want n'*t, where ' is the transpose operator in matlab.

 r = 1 - exp (-kp*n'*p.^a)

Subject: how do i overcome the mtimes error on this input

From: raaj kumar

Date: 9 Nov, 2010 15:00:05

Message: 4 of 6

"Steven_Lord" <slord@mathworks.com> wrote in message <ibbmmr$5uh$1@fred.mathworks.com>...
>
>
> "raaj kumar" <tambalan30@yahoo.co.uk> wrote in message
> news:ibblg8$ffd$1@fred.mathworks.com...
> >>> r = 1 - exp (-kp*n*p.^a)
> >
> > n = [0:1:10]; p = [0:10:650]; a =2.8; kp = 4.14E-8
> >
> > it keeps coming up with the mtimes error, what am i writing wrong here
> > guys?
> >
> > im a newbie to this programme so please take it easy on me if the mistake
> > is really obvious :S
>
> * is MATRIX multiplication.
> .* is ELEMENTWISE multiplication (note the leading period.)
>
> In this case, neither will work as the number of columns in n is not the
> same as the number of rows in p, nor are they the same size.
>
> What are you looking to compute with this expression? Are you looking for a
> numel(n)-by-numel(p) array [or that array's transpose?]
>
> Please respond _on the newsgroup_.
>
> --
> Steve Lord
> slord@mathworks.com
> To contact Technical Support use the Contact Us link on
> http://www.mathworks.com


basicalle r in this case is the amount of protein release, and n and p are the number of passes thru a homogeniser and th pressure respectively. I want to draw up a graph showing how r changes with changing values for n and p..

Subject: how do i overcome the mtimes error on this input

From: raaj kumar

Date: 9 Nov, 2010 16:27:04

Message: 5 of 6

"Sean " <sean.dewolski@nospamplease.umit.maine.edu> wrote in message <ibbmnk$7is$1@fred.mathworks.com>...
> "raaj kumar" <tambalan30@yahoo.co.uk> wrote in message <ibblg8$ffd$1@fred.mathworks.com>...
> > >> r = 1 - exp (-kp*n*p.^a)
> >
> > n = [0:1:10]; p = [0:10:650]; a =2.8; kp = 4.14E-8
> >
> > it keeps coming up with the mtimes error, what am i writing wrong here guys?
> >
> > im a newbie to this programme so please take it easy on me if the mistake is really obvious :S
>
> Hi Raaj,
>
> type
> whos
> at the command line.
>
> You'll see that n is 1x11 and p is 1x66. For a matrix multiplication to work the inner to dimensions in this case (n*p), the 2nd dimension of n and first of p must be the same. Make sure it's what you want, as far as a result, but I think you want n'*t, where ' is the transpose operator in matlab.
>
> r = 1 - exp (-kp*n'*p.^a)







This is not what i want to do...i think i understand what is needed but i dont knw how to write it. Firstly i want to see how r changes over n (which ranges from 1 to 10, with increments of 1). And I also want to see what the different values of p has on the r. So the x-axis should read n values, the y axis should read r values and there should be different lines which denote the value of p. I know i have to use a for loop for each and every n value otherwise i get a mtimes error , and indices but how would i go about it:

Subject: how do i overcome the mtimes error on this input

From: Sean

Date: 9 Nov, 2010 16:41:03

Message: 6 of 6


> This is not what i want to do...i think i understand what is needed but i dont knw how to write it. Firstly i want to see how r changes over n (which ranges from 1 to 10, with increments of 1). And I also want to see what the different values of p has on the r. So the x-axis should read n values, the y axis should read r values and there should be different lines which denote the value of p. I know i have to use a for loop for each and every n value otherwise i get a mtimes error , and indices but how would i go about it:


So something like this?:

n = [0:1:10];
p = [0:10:650];
a =2.8;
kp = 4.14E-8;

r = 1 - exp(-kp*bsxfun(@times,(p.^a)',n));

figure; hold on
for ii = 1:length(n)
    plot(r(:,ii));
end

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