How to adjust value from matlab-mfile and feedback in simulink

I am having a model in simulink uploaded at:
<http://www.freeimagehosting.net/79moh. >
In the first iteration the model should take value from matlab mfile and calculate error for Pid as e=r-i where 'i' is the value taken from matlab mfile but after that it should take feedback and calculate the error as e=r-y where 'y' is the value of feedback from space state. How can I do that in simulink. Any guidance?

 Réponse acceptée

Muruganandham Subramanian
Muruganandham Subramanian le 5 Déc 2012
Modifié(e) : Muruganandham Subramanian le 5 Déc 2012
step1:Initialize all i/p data in m-file & variable 'i'
step2: use 'sim()' command to run your model
step3: store the value of 'y' in baseworkspace by 'To workspace' block from model
step4:calculation

8 commentaires

Sir I have tried using these commands even then the value of simin is not updated I have attached the code and the updated block diagram is uploaded at< http://www.freeimagehosting.net/aauvl>. Please suggest me further changes.
clc
clear all
close all
Tstop=10;
simin=[0 0]
options =simset('SrcWorkspace','current');
sim('pidtry',Tstop,options)
simin=simout3
Insteadof using 'simin', you can do this by creating closed(feedback) loop by output signal(simout) followed by 'unit delay(1/z)' then to subtraction block.Initial condition for delay block is '0'.
Beenish Mazhar
Beenish Mazhar le 6 Déc 2012
Modifié(e) : Beenish Mazhar le 6 Déc 2012
sir I guess this is what you are saying which I have uploaded at http://www.freeimagehosting.net/na4ts. But sir then where shall I give the initial value from m-file. Kindly guide me.
check this:
<<C---Users--Admin--Desktop--New-nbsp-picture.jpg>>
Sir the link or code in your comment is not given.
constant->'(+-)' block->(-)simin(Insteadof this) %simin is not needed
From output(i.e.simout3)--> use 'unit delay'(1/z)block from simulink library, initial codition as '0'(i.e.zero) in delay block and then connect to (-)sign of add block
Thank you sir for your reply.Sir in the link given above I have done the same work and I have used the simin command because it is not necessary that initial value taken from mfile is zero, it may vary i.e simin initial value could be 2 or 5 etc.Kindly now tell me how to resolve the issue
Initial condition in unit delay is user specified. so you can give any value like 0 or 2 or 5 or etc...

Connectez-vous pour commenter.

Plus de réponses (0)

Produits

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by