Using the built in function in matlab Meanfreq to calculate the mean frequency of my signal, which is recorded with sensors that have an upper and lower reliable range (70kHz to 500 kHz).
According to the help (https://uk.mathworks.com/help/signal/ref/meanfreq.html#d117e104641) I should be able to specify this reliable range, but when I do this the value MeanFreq returns is outside this range (0.176 kHz) which is clearly not correct.
Anyone know any tips or tricks?
TIA
The code I use w/o the Freqrange is:
Fs = 1e6;
figure()
meanfreq(signal, Fs)
Then with the Freqrange I have
freqrange = [70,500];
Fs = 1e6;
figure()
meanfreq(signal, Fs, freqrange)
If I try
freqrange = [7e4, 5e5];
I get the error:
> Error using psdparserange>parseTime (line 103) The frequency range
> must be within the range of F for the specified input.
Edit - Trying
Fs = 1e6;
figure()
meanfreq(signal, Fs)
figure()
meanfreq(signal,freqrange)
Produces a load of errors.
Error using meanfreq
Expected input number 1, Pxx, to be nonnegative.
Error in psdparserange>parsePSD (line 121)
validateattributes(Pxx,{'numeric'},{'2d','nonnegative'}, funcName,'Pxx',1);
Error in psdparserange (line 40)
[Pxx, F, Frange, rbw] = parsePSD(funcName, varargin{1:min(n,3)});
Error in meanfreq (line 63)
[Pxx, F, Frange, rbw, extraArgs, status] = psdparserange('meanfreq', kaiserBeta, varargin{:});
Error in Main_analysis_Fullsignal (line 30)
meanfreq(signal,freqrange)
I believe this was a compataility issue - once I started using the 2019b version of matlab instead of 2017a I had no problem.
Related
I want to train an Artificial Neural Network on matlab r2020a for an automatic voltage regulator, I already have a simulink file for my output, but whenever I want to run this code:
I = out.input';
T = out.output';
net=newff(minmax(I),[3,5,1],{'logsig','tansig','purelin'},'trainlm');
net = init(net); % Used to initialize the network (weight and biases)
net.trainParam.show =1; % The result of error (mse) is shown at each iteration (epoch)
net.trainParam.epochs = 10000; % Maximum limit of the network training iteration process (epoch)
net.trainParam.goal =1e-12; % Stopping criterion based on error (mse) goal
net=train(net,I,T); % Start training the network
I keep facing this error:
Unrecognized function or variable 'procInfo'.
Error in nnMex.netHints (line 143)
processingInfoArray = [processingInfoArray procInfo];
Error in nncalc.setup1>setupImpl (line 201)
calcHints = calcMode.netHints(net,calcHints);
Error in nncalc.setup1 (line 16)
[calcMode,calcNet,calcData,calcHints,net,resourceText] = setupImpl(calcMode,net,data);
Error in nncalc.setup (line 7)
[calcMode,calcNet,calcData,calcHints,net,resourceText] = nncalc.setup1(calcMode,net,data);
Error in network/train (line 361)
[calcLib,calcNet,net,resourceText] = nncalc.setup(calcMode,net,data);
Error in ann (line 8)
net=train(net,I,T); % Start training the network
I'm not sure where to start to my search for this problem, but I think it might be a compiler issue
I tried searching online, but all I got was just suggestion to download compilers and toolboxes.
The function is as expected:
%% plot 3D plot with true color marker
plot_Lab(4,Lab,1,'',12,0);
plot_Lab(mode,Lab,createnewfig,markercolor,markersize,storeme)
% This function visualizes several different CIE-Lab_plot plots from
% CIE-Lab coordinate data in 'Lab'.
I enter this:
plot_Lab(4,[45.9470,1.5130,5.2120],1,'',12,0);
and get the following error messages
Error using lab2xyz (line 25)
Incorrect number of columns in LAB data.
Error in applycform (line 88)
out = c.c_func(columndata, cdata{:});
Error in applycformsequence (line 11)
out = applycform(out, cforms{k});
Error in applycform (line 88)
out = c.c_func(columndata, cdata{:});
Error in plot_Lab (line 68)
RGB = applycform(Lab',cform);
Does anyone know where I got it wrong? Please help.
plot_Lab is not a built-in function. Therefore you are supposed to provide its code or link, so one could follow you.
According to the link,
% Lab [3 x n] -> Lab coordinates of n datapoints
Lab is supposed to be 3 x n. What you are provided is 1 x 3. So, you probably need to transpose it:
plot_Lab(4, [45.9470,1.5130,5.2120].', 1, '', 12, 0);
I have code that, when run, should correctly use Lagrange Multipliers to find the maximum/minimum of a function here:
clear all
syms x y L;
f = x^4+2*y^4;
g = x^2+5*y^2+2*y^2-10;
firstpart=jacobian(f,[x y])-L*jacobian(g,[x y]);
[Lsoln,xsoln,ysoln]=solve(firstpart,x^2+5*y^2+2*y^2-10);
subs(f,{x,y},{xsoln,ysoln})
% The coordinates that correspond with the greatest and smallest values
% above are the maximum and minimum, respectively.
However, when I run it, I get four errors:
Error using sym.getEqnsVars>checkVariables (line 92) The second
argument must be a vector of symbolic variables.
Error in sym.getEqnsVars (line 62)
checkVariables(vars);
Error in solve>getEqns (line 450) [eqns, vars] =
sym.getEqnsVars(argv{:});
Error in solve (line 225) [eqns,vars,options] = getEqns(varargin{:});
Could anyone help?
You are passing two equations as individual arguments zu solve, that is not possible. You have to put both into an array
[Lsoln,xsoln,ysoln]=solve([firstpart,x^2+5*y^2+2*y^2-10] );
I have tried to calculate adjacent pixel correlation of 2 images. I am getting the answer for the encrypted images but not for the original plain text image.
It's showing some error which i am unable to understand. I have given the code which i used below along with the error message.
Please help.
P = imread('cameraman.tif');
x1 = P(:,1:end-1);
y1 = P(:,2:end);
r_xy1 = corrcoef(x1,y1);
scatter(x1,y1);
For this I am getting an error message:
Error using bsxfun Mixed integer class inputs are not supported.
Error in cov (line 93) xc = bsxfun(#minus,x,sum(x,1)/m); % Remove
mean
Error in corrcoef>correl (line 209) r = cov(x);
Error in corrcoef (line 92) r = correl(x);
Error in apc_PT (line 4) r_xy1 = corrcoef(x1,y1);
The same code worked for encrypted image. Dont know what's wrong.
You should cast the result of imread to double:
P = double(imread(...));
This will fix your error with corrcoef.
Edit Also, as noticed in the comments you have to use vectors in scatter:
scatter(x1(:), y1(:));
Best,
I'm trying to blur a grayscale image using Gaussian low pass filter( 5*5 kernal).I tried the following code.
I = imread('Lena.png');
G = fspecial('gaussian',[5 5],2);
Ig = imfilter(I,G,'same');
imshow(Ig);
But I'm getting an error in file 'meshgrid.m' as follows.
Error: File: meshgrid.m Line: 1 Column: 5
The input character is not valid in MATLAB statements or expressions.
Error in fspecial (line 145)
[x,y] = meshgrid(-siz(2):siz(2),-siz(1):siz(1));
Error in Untitled2 (line 2)
G = fspecial('gaussian',[5 5],2);
I'm not understanding what the error is.Can anyone help me please.The input image that I used is uploaded below('Lena.png').Thanks in advance