which block to use for feedback loop in simulink

x1=x0+y;
x2=x1+y;
x3=x2+y;
where x0=initial value,,,and x value should be updated continuously ,,this I wanted to implement in simulink,,,and I have developed this with using "unit delay" block,,,but for further am changing some values of equation run time ,,,that time my "unit delay" block is starting calculation again from the initial value,,,rather i want my unit delay to take value of present calculated x value,,,,,,,,or anybody can suggest which is the best block to use for feedback loop,ehich takes initial value from defined value and next value from the feedback loop

Answers (1)

Both Unit delay and Memory blocks work fine.

7 Comments

ya I tried with both,,,But wen i change some values of the model ,,the unit delay block is taking its initial value(x0)always,,,rather i want to updated x value
https://picasaweb.google.com/100600576001599595108/MATLABSimulink#5833555322759653890 HAve a look on my model where am using a memory block and memory block value am initially am setting up and in the next cycle it should take from feedback loop,,,and while model running i will change the value of -C- block,,,but my model is calculating from starting again,,ie my memory block will take initail value when i change the -C- block
(FYI, the image link doesn't work)
How do you change the value of the Constant block? Is it a variable in the workspace? If yes, you have to run set_param('modelname', 'SimulationCommand', 'update') or Ctrl+D on the model window to force Simulink to take note of the new value.
ya,,I have constant as variable,,,and it takes new value from gui also,,,but it considers a new entered value and removes the old values of x,,,rather i want keep all the values of x
Wen i change my constant variable value ,,,i will pass current value to memory block,and my module start comapring memory block and constant block,,, Suppose memory block=10:,constant=20:,,,and wen i change value of my constant block,ie ,constant=35,,,it starts calculation from memory block=20; constant =35,,,,rather i wanna keep the value of memory block from initial ie,memory block started from 10 ,,,,,,(memory=10 11 12 13 14 15 16 17 18 19 20 20 20 20 reached and next value should be 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 35 35 35 like this it should flow)but presently am getting(memory= 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 35 35 35 )when i change the value of constant block
Arun, post your code which pauses and coninues your simulation
function pushbutton3_Callback(hObject,eventdata)
f441= figure('MenuBar','none','Position', [550,500,300,140],'Name','Position Update','NumberTitle','off','color',[0.933 0.835 0.835]);
% push button for editing values of speed and course of firing platform
PB31= uicontrol('Style','pushbutton','String','Firing Platform','Position',[10,80,90,25],'FontAngle','italic','Callback',{@pushbutton212_Callback});
% push button for editing values of speed and course of Target platform
PB32= uicontrol('Style','pushbutton','String','Target Platform','Position',[150,80,90,25],'FontAngle','italic','Callback',{@pushbutton222_Callback});
%%%%%To display a course and speed of user defined values
% This push buttons callback for Firing platform
function pushbutton212_Callback(hObject,eventdata)
prompt = {'Enter Course:', 'Enter Speed:'};
title = 'Course&Speed';
lines = 1;
def = {'Course', 'Speed'};
answer = inputdlg(prompt, title, lines, def);
[Course_F Speed_F]= answer{:} %Put the user entered value in a structure course and speed
w=str2num(Course_F); %Convert string entered to numeric type
c=num2cell(w); %Convert numeric to cell type
d=cell2mat(c); %Convert from cell to matrix format
e=str2num(Speed_F);%Convert string entered to numeric type
f=num2cell(e); %Convert numeric to cell type
h=cell2mat(f); %Convert from cell to matrix format
assignin('base','Course_F',d);%assign the value of course to workspace
assignin('base','Speed_F',h)%assign the speed value to the workspace
a = VALUE_NEW
set_param('C:\Documents and Settings\admin\Desktop\New Folder (5)\02_12_2012(Simulink blocks)\Resolved Models\Speed+Position+Course\course_speed_position.mdl', 'SimulationCommand','update')
end
end

Sign in to comment.

Products

Tags

Asked:

on 15 Jan 2013

Community Treasure Hunt

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

Start Hunting!