Author Topic: Matlab Question(s)  (Read 2135 times)

0 Members and 1 Guest are viewing this topic.

Offline KaramelTopic starter

  • Regular Contributor
  • *
  • Posts: 178
  • Country: tr
Matlab Question(s)
« on: March 05, 2017, 02:41:51 pm »
Hi,

I am, now, learning matlab coding. I want to identify this function which at below. Before asking question, I looked up matlab's help but I really did not understand anything. How can I define this state function?



P.s: ss command heps to us but actuallty, I did not understand using ss command.
« Last Edit: March 05, 2017, 02:45:14 pm by Karamel »
 

Offline Caio Negri

  • Contributor
  • Posts: 26
  • Country: br
Re: Matlab Question(s)
« Reply #1 on: March 05, 2017, 03:20:55 pm »
You have a linear state space model defined in the standard format:

dx/dt=Ax+Bu
y=Cx+Du

x is the state vector of your system and dx/dt is the derivative of that, in your case you have 3 states. u is your input (or control) vector, y is your system ouput. A, B , C and D are matrices.

You can create this dynamic system model in matlab using the ss fucntion:
Code: [Select]
sys = ss(A,B,C,D); After that, use sys with any of the Matlab linear system analysis tools, for example:
Code: [Select]
bode(sys); %Plot the bode diagramsor plotting the step response for each input:
Code: [Select]
step(sys);
"Start where you are, use what you have, do what you can." - Arthur Ashe
 

Offline rstofer

  • Super Contributor
  • ***
  • Posts: 9890
  • Country: us
Re: Matlab Question(s)
« Reply #2 on: March 05, 2017, 05:05:40 pm »
I posted the matrices below.  'A' for example is entered as

A=[-10,16.5,-7;-8,12.5,-5;-4,6.5,-3]

'B' is a column vector so:

B=[4;3;2]

Code: [Select]
A =
  -10.0000   16.5000   -7.0000
   -8.0000   12.5000   -5.0000
   -4.0000    6.5000   -3.0000
B =
     4
     3
     2
C =
     1    -1     0
     0    -1     2
D =
     0
     1

Interesting project!  I had to buy the Control System Toolbox to run the simulation but it was worth it for the education.
 

Offline KaramelTopic starter

  • Regular Contributor
  • *
  • Posts: 178
  • Country: tr
Re: Matlab Question(s)
« Reply #3 on: March 05, 2017, 05:51:09 pm »
I have done it before read your comments, now, I couldnt find transfer function with using tf2ss function.

 


 

Offline f5r5e5d

  • Frequent Contributor
  • **
  • Posts: 349
Re: Matlab Question(s)
« Reply #4 on: March 05, 2017, 07:02:43 pm »
free options can be good

Scilab is free, has some serious support, has simailar toolboxes https://www.scilab.org/scilab/features/scilab/control
but often the toolboxes aren't as complete as Matlab's

Ocatve is supposedly more nearly Matlab compatible,  .m files run with  fewer modfications
 

Offline Caio Negri

  • Contributor
  • Posts: 26
  • Country: br
Re: Matlab Question(s)
« Reply #5 on: March 05, 2017, 08:07:29 pm »
I have done it before read your comments, now, I couldnt find transfer function with using tf2ss function.

1st of all, you want to use the ss2tf function since you're converting from state space to transfer function. Also bare in mind your system has 2 outputs so you need 2 tranfer funcions to describe it. Here's an example:
Code: [Select]
A=[-10,16.5,-7;-8,12.5,-5;-4,6.5,-3];
B=[4;3;2];
C=[1,-1,0;0,1,-2];
D=[0;1];

[b,a] = ss2tf(A,B,C,D); % Tranfer function coeficients (b will have 2 rows)
sys1=tf(b(1,:),a); % Tranfer function of output 1
sys2=tf(b(2,:),a); % Tranfer function of output 2

sys1
sys2

figure(1)
step(sys1);
figure(2)
step(sys2);

If you need help with any specific function, just type "help function_name" in the command window and matlab will display all the documentation for it.
« Last Edit: March 05, 2017, 08:16:53 pm by Caio Negri »
"Start where you are, use what you have, do what you can." - Arthur Ashe
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf