Got Questions? Get Answers.
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:
matrix for calculation

Subject: matrix for calculation

From: relgn ng

Date: 8 Jun, 2012 05:34:22

Message: 1 of 4

function [kr1, ka1, K1rot] = calculateKrKa(Fa, Z, Alpha, Di, Pi, Do, Po, N, d, dm)
Fan = Fa .* 9.80665 / 1000;
Alpharad = Alpha.* pi / 180;

w = Z .^ (2/3) .* Fan .^ (1/3);
z = Di * Pi ^ (1/3) + Do * Po ^ (1/3);
x = cos(Alpharad)^2;
t = sin(Alpharad)^2;
q = sin(Alpharad)^(1/3);

kr1 = (0.538*10) .* w .* x ./ z ./ q;
ka1 = (1.075*10) .* w .* t ./ z ./ q;

%K1rotational calculation
kz = ka1/(2*N);
kr = kr1/N;
r = dm/2;
K1rot = N*((r^2)*kz + (d^2)*kr);

Alpha is a 1x10 array. Fa is also a 1 x 10 array. how can i get this to work?
 

Subject: matrix for calculation

From: Steven_Lord

Date: 8 Jun, 2012 14:08:45

Message: 2 of 4



"relgn ng" <dream_winder@hotmail.com> wrote in message
news:jqs2su$alu$1@newscl01ah.mathworks.com...
> function [kr1, ka1, K1rot] = calculateKrKa(Fa, Z, Alpha, Di, Pi, Do, Po,
> N, d, dm)
> Fan = Fa .* 9.80665 / 1000;
> Alpharad = Alpha.* pi / 180;
> w = Z .^ (2/3) .* Fan .^ (1/3);
> z = Di * Pi ^ (1/3) + Do * Po ^ (1/3); x = cos(Alpharad)^2; t =
> sin(Alpharad)^2;
> q = sin(Alpharad)^(1/3);
>
> kr1 = (0.538*10) .* w .* x ./ z ./ q;
> ka1 = (1.075*10) .* w .* t ./ z ./ q;
> %K1rotational calculation
> kz = ka1/(2*N);
> kr = kr1/N;
> r = dm/2;
> K1rot = N*((r^2)*kz + (d^2)*kr);
>
> Alpha is a 1x10 array. Fa is also a 1 x 10 array. how can i get this to
> work?

Can you be more specific? What are the values (or at least the sizes) for
the other eight input arguments and what error/warning/wrong answer do you
see when you try to run this function? If you post this information
(including the FULL text of any error or warning message you receive) to the
newsgroup someone may be able to offer a suggestion.

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

Subject: matrix for calculation

From: relgn ng

Date: 11 Jun, 2012 02:06:07

Message: 3 of 4


> Can you be more specific? What are the values (or at least the sizes) for
> the other eight input arguments and what error/warning/wrong answer do you
> see when you try to run this function? If you post this information
> (including the FULL text of any error or warning message you receive) to the
> newsgroup someone may be able to offer a suggestion.
>
> --
> Steve Lord
> slord@mathworks.com
> To contact Technical Support use the Contact Us link on
> http://www.mathworks.com

??? Error using ==> mpower
Inputs must be a scalar and a square matrix.

Error in ==> ProjectIX>calculateKrKa at 268
x = cos(Alpharad)^2;

Error in ==> ProjectIX>pushbutton1_Callback at 677
[kr1, ka1, K1rot] = calculateKrKa(Fan, Z, Alpharad, Di, Pi, Do, Po, N, d, dm)

Error in ==> gui_mainfcn at 96
        feval(varargin{:});

Error in ==> ProjectIX at 42
    gui_mainfcn(gui_State, varargin{:});

Error in ==> @(hObject,eventdata)ProjectIX('pushbutton1_Callback',hObject,eventdata,guidata(hObject))

 
??? Error while evaluating uicontrol Callback

Fan is a 10 x 1 array, alpha is also 10x 1 array. I wanna feed this two array into a equation to give me 10 results. And to display this results on a table.

Subject: matrix for calculation

From: Steven_Lord

Date: 11 Jun, 2012 13:43:27

Message: 4 of 4



"relgn ng" <dream_winder@hotmail.com> wrote in message
news:jr3jqf$jbn$1@newscl01ah.mathworks.com...
>
>> Can you be more specific? What are the values (or at least the sizes) for
>> the other eight input arguments and what error/warning/wrong answer do
>> you see when you try to run this function? If you post this information
>> (including the FULL text of any error or warning message you receive) to
>> the newsgroup someone may be able to offer a suggestion.
>>
>> --
>> Steve Lord
>> slord@mathworks.com
>> To contact Technical Support use the Contact Us link on
>> http://www.mathworks.com
>
> ??? Error using ==> mpower
> Inputs must be a scalar and a square matrix.
>
> Error in ==> ProjectIX>calculateKrKa at 268
> x = cos(Alpharad)^2;

Alpharad is a vector. Therefore so is cos(Alpharad). The operation x^2 is
basically the same as x*x (using MATRIX multiplication) and that's only
defined for square matrices x. cos(Alpharad) does not return a square
matrix, so you cannot raise it to the second power using MATRIX power.

What you can do is to raise _each element of cos(Alpharad)_ to the second
power using the .^ operator (which corresponds to ELEMENTWISE power, just
like .* corresponds to ELEMENTWISE multiplication) instead.

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

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