I am trying to create a delay block in simulink that has 3 options within it. The 3 options I want is a x, y, and z. I would like to be able to choose different types of statistical probability functions within each one. However, I am having a hard time finding in documentation on this. Any help would be greatly appreciated.
Related
I have some reflectivity data which I am going to convolute with a vibroseis (Klauder) wavelet to get a seismic trace. i am struggling to do the code. I need it to have a sweep from 2500Hz to 7000Hz with a duration of 0.03s (30ms). i have downloaded the CREWES toolbox with the different wavelet functions in but i dont know how to produce it. can anyone help?
Welcome to SO.
You may want to check pp.7 to 10 of this ebook.
There are two ways to do this. You may:
Create your klauder wavelet from scratch. This is the approach detailed here.
Call the klauder function predefined in the CREWES package, as described in the ebook. In this case, you will directly specify the min and max frequencies used for your sweep as arguments in the function: [wk,twk]=klauder(fmin,fmax,dt,slen,tlen,staper);
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.
I apologise if this is quite obvious to some however I have been trying to get my head around bootstraps for a few hours, and for something so simple I am really struggling.
I have a large data set, however it is not normally distributed and am trying to find the confidence levels, hence why I have turned to bootstraps. I want to apply the bootstrap to the fourth column of a data set, which I can do.
However I am having trouble with the bootci function itself
ci=bootci(10000, ..... , array;
I am having trouble implementing the function, as I don't fully understand what the 2nd part of the bootci function, denoted ....., does.
I have seen #mean implemented on other examples, I'm assuming this calculates the mean for each column and applies it to the function.
If anyone could confirm my thinking or explain the function to me it would be much appreciated!
I am also unsure about how to change the sample size, could someone point me in the right direction?
From what I understand of the question:
ci = bootci(10000, #mean, X);
Will determine a 95% confidence interval of the mean of the dataset X using 10000 subsamples generated using random sampling with replacement from dataset X.
The second argument of the function #mean indicates that the function to apply to the subsamples is mean, and hence to calculate the confidence interval of the mean. You could equally pass in #std to calculate a confidence interval on the standard deviation if you wanted, or pass in any other suitable function for that matter.
From what I have read in the documentation, it does not seem to be possible to directly control the size of the subsamples used by the bootci function.
I was asked to implement the cross correlation in Matlab and compare it with the xcorr that Matlab provides.
From what I have searched its seems that cross correlation is similar to convolution but I still don’t fully understand how either of them work, so its impossible to get it down on code.
If somebody has done this before and is willing to share the code with a explanation on how it works is appreciated.
PS: I was told that I cant be using inbuilt functions other than the simple ones.(for, if, etc..)
I am sure you are familiar with this GIF from a convolution:
What do you see there? you calculate the value under two functions (the realtion between them is a multiplication), which is an integral (which in discrete system is a sum of the values inside your integration limits), and you do that for the whole integration limit in one function (so that's one inner loop) in every step of the integration limits of the other function , for the whole integration limit of the second function (nested in a second loop).
So there you have it, a convolution can be programmed as the sum of multiplications of the values of two functions inside two nested loops over the integration limits. For the cross correlation you just change one direction.
Try programming that and come back if it doesn't work. Good luck with your assignment!
I am trying to use ode45 in MAtlab and want to fix the number of points that MAtlab uses (number of time steps). Using the 'refine' option in ode45 seems not to help. For instance, if I set 'refine' to be 10, Matlab returns an array of 101.
Changing 'RelTol' and 'AbsTol' also does not help either. I know that it is possible to write tspan as [0,t1,t2,t3,...,tn] and that solves this issue, but I'd like to fix number of points via the 'refine' option.
Perhaps you misunderstand what the 'Refine' option actually does. From the documentation for odeset:
Refine — If Refine is 1, the solver returns solutions only at the end of each time step. If Refine is n >1, the solver subdivides each time step into n smaller intervals and returns solutions at each time point. Refine does not apply when length(tspan)>2 or the ODE solver returns the solution as a structure.
In other words, setting 'Refine' to 10 does not guarantee that you'll get 10 output points but rather that you'll get 10 output points per integration time step. In the case of an adaptive step size method like ode45, the solver chooses how big the steps are based on many criteria. If you want a given number of output points you must specify fixed time steps as you've already done via tspan. The linspace function might be helpful to you.
Another possibility is that you're not actually applying your options. Simply calling odeset is not sufficient. You must also remember to pass the output into ode45.