Help! plotting transfer function in matlab

  • MATLAB
  • Thread starter cupcake
  • Start date
  • #1
76
0
Hello, I need a help here, cause I only have basic matlab.. I want to superimpose two transfer function,

Gp(s)=(Kp/sT+1)*e^(-sL) in frequency domain,
in time domain y(t)=Kp*(1-exp(t-T)/L)*1(t-L)
where, the value of Kp, T and L are known.. and t is matric time from 0-24.5 [0, 0.5, 1....24.5]

how to write y(t) in matlab code? when I just wrote the y(t) as I wrote above, I got this error msg : Error using ==> mtimes
inner matrix dimensions must agree
 

Answers and Replies

  • #2
Pythagorean
Gold Member
4,214
273
anywhere you have an multiplication or division operation on a vector, you have to specify how you want it multiplied. In your case, you have to a put a period '.' in front of each case of multiplication and division, so that you have

A.*X

assuming that X is a vector and A is a constant
 
  • #3
76
0
ok now I have a variable Y which is a matric 49x1 and Phi which is a matric 50x2
when I perform this formula
theta=inv(Phi'*Phi)*Phi'*Y
I got this error again
??? Error using ==> mtimes
Inner matrix dimensions must agree.

can anyone advise? how to use inverse function? also not very sure about "....'...." there
 
  • #4
Pythagorean
Gold Member
4,214
273
ok now I have a variable Y which is a matric 49x1 and Phi which is a matric 50x2
when I perform this formula
theta=inv(Phi'*Phi)*Phi'*Y
I got this error again
??? Error using ==> mtimes
Inner matrix dimensions must agree.

can anyone advise? how to use inverse function? also not very sure about "....'...." there

because inner matrix dimensions must agree. How would you multiply a 49 length vector with a 50 length vector even without a computer?
 
  • #5
15
0
ok now I have a variable Y which is a matric 49x1 and Phi which is a matric 50x2
when I perform this formula
theta=inv(Phi'*Phi)*Phi'*Y
I got this error again
??? Error using ==> mtimes
Inner matrix dimensions must agree.

can anyone advise? how to use inverse function? also not very sure about "....'...." there

I suspect you are not using the same time interval for Phi and Y since Phi is one unit longer.

Secondly, you should only be using the "...'..." function to switch the dimensions of your vector (eg, if X is a vector with dimensions [5,1] then X' is a vector with dimensions [1,5]); I typically do this (when appropriate) to make the inner matrix dimensions agree (eg, you cant multiply a matrix with dimension [5,1] by one that is [1,5]; so you can NOT multiply X.*X' because the dimensions do not match).

What is the meaning of your equation where you have inv(Phi.*Phi')? It looks like you are trying to use the definition AND function of an inverse matrix. First of all, your matrix MUST be square to do this [eg, dimension [2,2], or [3,3], etc).

Recall:

Code:
 A = [a,b; c,d];
Inverse = A*A^-1;
Inverse = 1/|A|*[a,-b;-c,d]; 
|A| = a*d-b*c;

so if

a = [1,2;3,4];
% where the mag of a is 1*4-2*3 = -2;
b = inv(a)
b = [-2,1; 1.5,-.5]

Hope that is somewhat helpful!
 
Last edited:
  • #6
76
0
I was bluntly given the mat lab code, so I don't know exactly what's going on, what they need me to do is now like changing the variables.. actually that formula is for finding the transfer function by using least square method...
 
  • #7
76
0
or, anyone could give me the code for least square method??
 

Related Threads on Help! plotting transfer function in matlab

Replies
1
Views
21K
Replies
1
Views
2K
  • Last Post
Replies
1
Views
4K
  • Last Post
Replies
2
Views
33K
  • Last Post
Replies
2
Views
6K
  • Last Post
Replies
2
Views
2K
Replies
4
Views
6K
  • Last Post
Replies
3
Views
11K
  • Last Post
Replies
1
Views
37K
Replies
3
Views
2K
Top