# Simulation Simulink Matlab

I have a regular wave equation to simulate on MATLAB Simulink :

**Equation**:

Fw(t) = Awave F(w) cos(wt + g)

- Fw= Wave existing force;
- Awave= Amplitude of wave= Wave Height/2;
- t = time= 5 AM, 11 AM, 5 PM, 11 PM;
- w = corresponding frequency = 2*pi/T;
- T = Period of wave;
- g = 0;

where, Awave, Fw and T vary with t.

Can you please give me an idea? Specially using Simulink MATLAB Function!

## Answers

Feed Awave, Fw, T and t as inputs to your MATLAB Function, which should look something like this if I understood correctly:

function Fw = wave_fun(Awave,Fw,T,t) w = 2*pi/T; g = 0; % change if need be Fw = Awave * cos(w*t+g);

Note that t is the simulation time in s (you can use a Clock block for that). The other variables need to be defined as a function of time in the base workspace and then you can use From Workspace blocks.

However, this is so simple that a MATLAB Function is unnecessarily complicated in my opinion. Simple mathematical blocks should suffice to combine the inputs and compute the desired output.