Simulink and Matlab - simulink

I just wanted to plot BER curve of FSK modulation using monte carlo(bertool)--theoretical curve against the exact one but i'm getting the following problem:
I was expecting that there would be no errorit shows that index exceeds the number of array elements. Index of array must not exceed 1

Related

Can I use the in-built function 'mle' for Maximum Likelihood Estimate that maximizes the log-likelihood of a vector in MATLAB for this purpose?

In my work I have a vector of particular length 'L'. I want to maximize the log-likelihood estimate of the vector using maximum likelihood estimation. I have followed the following procedure:
x=[vector(1:L)];
pd = fitdist(x,'Normal');
z=log(normpdf(x,pd(1),pd(2)); %for finding log-likelihood
However, I do not know whether the above program maximizes the log-likelihood. I am getting a scalar value in 'z', can I use that scalar value to plot back the desired signal? The distribution is assumed to be Normal distribution. Is there any other way to do the problem?

How to calculate gradient and correlation coefficients with moving window in matlab?

I am working on pedestrian step detection algorithm (acceleration data), I need to calculate statistical features from my filtered signal not raw data. I have already calculated mean, var and std and now I want to calculate correlation coefficients and gradient from filtered data. My filter data is of 1x37205 double. I calculated these features using for loop with moving window size=2samples and 50% overlap of previous window. Below I am attaching the code I tried. But when I run this for corrcoef it gives 1's as output for the whole data and for gradient it gives error Assignment has more non-singleton rhs dimensions than non-singleton subscripts. I am unable to understand well. Could some one suggest me or provide any code help in matlab and/or how can I work on that?
windowsize=2;
%%C is used for corrcoef and G for gradient. %%Data_filtered is caclulated
%%from acceleration xyz.
function [C, G] = features(Data_filtered, window)
C=zeros(length(Data_filtered),1);
G=zeros(length(Data_filtered),1);
for i=window:(length(Data_filtered))
C(i,1)=corrcoef(Data_filtered(i+1-window:i));
end;
for i=window:(length(Data_filtered))
G(i,1)=gradient(Data_filtered(i+1-window:i));
end;
end

Inner matrix dimensions must agree error and how to setup separate arrays based on frequency response data?

I am using the frd function to get a frequency response of several systems at discrete reduced frequencies. I am having issues with setting a range of frequencies instead of manually inputting one by one and looking at the response (Error: Matrix dimensions must agree). Also, after inputting the range of frequencies and getting 2x2 response matrices, how can I extract each element of the matrices and store them in a separate array so I can use the bode plot at the specified range of reduced frequencies?
Below is my code:
%Theodorsen's function at discrete reduced frequencies
k = 10e-20:0.01:10; %discrete reduced frequency range
Ck = (besselh(1,2,k))./(besselh(1,2,k)+1i*besselh(0,2,k)); %Bessel function
%2x2 Matrices
A=[0.8132 -0.1008; -0.0725 2.0518];
B=Ck*[7.623 57.15; -8.233 -57.157];
C=Ck*[1865 1473.14; -1119 11907.48];
%Input Matrix
D=[-1243.028; -2386.614];
%FRD function
sys1=frd(A,k)
sys2=frd(B,k)
sys3=frd(C,k)
%bode(sys1)
%bode(sys2)
%bode(sys3)

3D Matrix in Simulink which can be 2D is not supported

I am using SIMULINK and I needed to define a Rotation Matrix 3,3,N where N is the number of Robots which I am trying to simulate. To do that, because I am also using the Simulink Coder I had to define the signal related to this matrix as Variable Size and I had to define the upper-bound in the following way:
The problem is that when I want to use only one robot (I set n_robots to 1) I get the following error.
Cannot initialize dimensions of 'R' of 'test_pos_ctrl_target/rotation matrix to Euler angles' to [3x3x1]. When the number of dimensions of a matrix exceeds 2, the size of the trailing dimension must be greater than 1.
Someone could help me?
thanks a lot.
You can't have the last dimension as 1 because MATLAB treats any matrix of dimension [m,n,1] as [m,n]. See size() returns 1 where matrix dimension should not exist for more details.
Try defining R of size [n_robots,3,3] and then re-arrange the matrix inside your code (I assume you are using a MATLAB Function block).

Calculating Jaccard distance of a large matrix in Matlab

I have a large matrix of size 40K * 900K. It is a sparse, binary matrix and I would like to calculate the Jaccard distance between its rows (40K by 40K Jacard distance in total). I'm aware of built-in function pdist which calculates ths similarity for me, but due to matrix size it seems like it can't and it shows me the following error message.
Matrix is too large to convert to linear index.
Error in ==> pdist at 139
elseif any(imag(X(:)))
Any suggestion on how to resolve this problem?