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

which block to use for feedback loop in simulink

Asked by Arun Badigannavar on 15 Jan 2013
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

0 Comments

Arun Badigannavar

Tags

Products

1 Answer

Answer by Azzi Abdelmalek on 15 Jan 2013

Both Unit delay and Memory blocks work fine.

7 Comments

Arun Badigannavar on 16 Jan 2013

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

Azzi Abdelmalek on 16 Jan 2013

Arun, post your code which pauses and coninues your simulation

Arun Badigannavar on 16 Jan 2013
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
Azzi Abdelmalek

Contact us