Designing a Matlab filter from a Laplace equation - filtering

I have a Laplace Transfer function that I wish to use in a high pass filter. I am trying to design a filter inside Matlab that will use this function using FDAtool but I don't understand how the parameters and coefficients this tool uses relates to the Laplace function I have.
Can anyone provide some information or links regarding the relationship between a function and the filter that uses it.

Why don't you simply use a Transfer Fcn block (or a Discrete Transfer Fcn block if it's discrete) since you already have the Laplace transfer function? FDAtool is for designing a filter as far as I know. It sounds like your filter is already designed.

Related

Mathematical modelling in Matlab

I am new to Matlab and I need to perform a simple task. I have an input function u(t)=2t-1 and an output function
y(t)=(-4/45)e^3t+ (1/5)e^(-2t)-1/3t-1/9
I have to find the corresponding behavior model, defined via a transfer function and then simulate the behavior model in Matlab/Simulink. I am not sure what approach I should use. What I have done so far is that I transferred the input and output function in the s-domain and then I calculated the transfer function. What does it mean to simulate the behavior model in Matlab? Can anyone please help me? I am a very beginner.
Thank you very much!
If you've already done the Laplace transform and calculated the transfer function in s-domain, I think it means applying the transfer function to an arbitrary transient input and calculating the response.
The transfer function is based on the response due to a unit step function.
If you have an input that is something other than a unit step function (e.g. a sinusoid), you'd calculate the response as follows:
Transform the arbitrary input function to s-space.
Multiply it by the transfer function to the response in s-space.
Transform the response in s-space back to the time domain.
This is how Laplace transforms work.

Reproducing a discrete filter block in simulink

I would like to make a discrete filter, where the sampling rate can be controlled by an input. I am trying to understand how the discrete filter block looks, "under its own mask." Is there anyway to retrieve the code behind this block so it can be modified for my use?
You can use an user-defined function as a filter, pick the filter transfer function, translate it into a difference equation (the discrete-time equivalant to the diferrential equation), implement that difference equation in a function and feed the sampling rate as an input (the sampling rate will appear as a constant in your difference equation).
The block is too complex and has too many options to simply be able to look under the mask. Your best option is to have a look at the documentation, which does show some detailed implementation of the block in some articular cases to get an idea and then try to recreate the discrete filter you want from basic building blocks, using a constant sample time at first, until you can validate your own implementation against the Simulink library block. Only then, start considering how you will change the sample time. Your main problem though is that the filter coefficients will change with the sample time, so you need to be able to re-calculate them on the fly. It's not an easy problem, I don't even know if it's possible.

How to Add external frequency inputs in the analog filter design block simulink in matlab

I want to be able to externally have inputs for the lower passband edge frequency and higher passband edge frequencies for the butterworth filter block in the simulink signal processing toolbox in matlab. How can I achieve this. Currently you'll have to click the block to specify these frequencies and this is not possible at runtime.
Regards,
Alfred
Basically you are asking for a filter that has time varying parameters. The Butterworth filter block does not allow for this, and cannot be modified to do so, so you are going to have to roll your own. This can be achieved in several ways:
Determining the difference equations that you need to implement, then creating a filter out of fundamental blocks (product, summation and unit delay blocks) where the "parameters" you want to change are fed into the product blocks as signals.
Using a block such as Transfer Fcn Direct Form II Time Varying. (This assumes you can parameterize the changes you need as a gain-scheduled signal.)
Write an S-Function (or perhaps a MATLAB Function block) to implement any detailed/specific functionality.

Patternsearch discrete variables

I want to optimize a multi-variable function with the patternsearch function in MATLAB. The function requires a lower and upper boundary and looks within the boundaries in a continuous domain.
I however have a discrete set of values in an excel file and would like the algorithm to search within this discrete domain instead of in the continuous domain.
Is this possible with patternsearch?
Maybe I don't understand correctly your question but if you have a (discret and finite) set of values, why don't you compute the function's value at these points and return the minium?
In short, no. That is not what patternsearch is intended for. Optimization techniques for discrete and continuous search spaces are quite expectedly different.
If you're looking for an approximate answer however, it is possible to use spline, polyfit, etc. to arrive at an approximate continuous function for your data and then apply patternsearch on it.
If you provide greater detail about your problem, I or someone else may be able to suggest a more suitable way of working with your data.
The best optimization tool for this is the Genetic Algorithm. This optimization tool comes with Matlab's global optimization toolbox and allows for optimization of both continuous and discrete variables at the same time.
In the genetic algorithm variables that are integers have to be declared as such. Non-declared variables are continuous by default.
Check the Global Optimization Toolbox guide for information on how it works: http://it.mathworks.com/help/pdf_doc/gads/gads_tb.pdf.

How to generate a curve using matlab simulink

How to generate the curve of transfer function:
G0(s)=exp(-s)*[(2s+4)/(s^3+5s^2+6s+4)]
using MATLAB and Simulink?
What kind of curve do you mean? Bode plot? Nyquist plot? Step response?
Use the tf function to create your transfer function with the InputDelay parameter to represent the exp(-s), see Models with Time Delays in the documentation for more details.
Once you have your transfer function, you can use functions like bode, nyquist, step, impulse, etc... to generate your "curve" of choice.
All of this requires the Control System Toolbox.