I want to make a simulation model of the given function. Can you help me ??
    4 Ansichten (letzte 30 Tage)
  
       Ältere Kommentare anzeigen
    
    Shiv Nileshkumar Matliwala
 am 13 Sep. 2022
  
    
    
    
    
    Kommentiert: Shiv Nileshkumar Matliwala
 am 15 Sep. 2022
            function y = fcn(u,t)
t_span = 10
y = u(t_span-t) ;
%input u = sin-wave
Here, this is the matlab function inside the matlab function block in simulink. Now as an input I have given sine wave with simulation time as a parameter not external signal as time. But now i want to use the time 't' inside the equation like given above inside the function equation. Then how can i define time 't' and use it inside the equation ??
0 Kommentare
Antworten (1)
  Walter Roberson
      
      
 am 13 Sep. 2022
        If t is simulation time, then it will likely be non-integer, and you would be trying to index by a non-integer.
If u were the sine function instead of being a signal, then
sin(t_span - t) = -sin(t - t_span)
which is negative of sin with a delay. It would probably be easier to take a sine wave generator and put it through a delay of t_span and then take the negative of the delayed signal -- which are all things you can do without using a MATLAB Function Block.
7 Kommentare
  Walter Roberson
      
      
 am 14 Sep. 2022
				https://www.mathworks.com/help/simulink/ug/code-generation-for-anonymous-functions.html says that anonymous functions are supported in MATLAB Function Blocks (as of R2016b if I understand correctly)
Siehe auch
Kategorien
				Mehr zu Sources finden Sie in Help Center und File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!