Grid Generation error - matlab

I have worked out one sample code for grid analysis.
But each time I am having an error.
Here is my error and my code.
I think am using the function in matlab wrongly. Can anyone please guide me on how to run the function in matlab?

You have to give the function some input
Analyse_Grid("put something here (wf value)")

Related

Can someone please explain how the function handle in this Matlab code works

Can someone please explain how the function handle in this code works! Currently, the code is not jumping to the function and I'm trying to fix it. And can You please explain, how can I write the same code without using the function handle. This code is written for a Matlab GUI.
%...
handles.Data.Audio.TimerFcn={#TimerFcn, handles};
%...
function TimerFcn(audio,~,handles)
set(handles.Graphics.Line(2,handles.AudioNum),'XData',handles.Data.TS.Time((handle.Data.k+1)*handles.Data.fs+audio.CurrentSample*[1,1]));
set(handles.Graphics.Line(2,handles.AudioNum),'Color' , 'y');
guidata(handles.Fig,handles);
So the code is using the function handle for "TimerFcn" function, and I don't really understand how this works. Therefore I can't fix the bug.
handles is not a function but rather a struct that stores information about the elements in your MATLAB GUI.
The rest of the code should help to solve your problem. What I can understand with the code you posted is that you are assigning function TimerFcn to the object in Data.Audio. So, if the function TimerFcn is not reached is because the object in charge of this function is not managing to run it, e.g. if it is a timer that has to wait X seconds before run this function, maybe it is not correctly set (or may be the waiting time is too high).
I hope I help you to understand the problem.

why the regression doesnt work? (MATLAB)

I have a accelerometer signal as below:
and I have a walking signal as below:
I tried to regress these two signal using regression. Here is the code:
regMat=zeros(size(walkVec,1),size(walkVec,2));
for i=1:size(data,1)
b=regress(walkAcc', walkVec(i,:)');
regMat(i,:)=walkVec(i,:)-repmat(b,1,length(walkAcc));
regData(i,:)=[data(i,1:(ipt(1)-1)),regMat(i,:), data(i,
(ipt(2)+1):size(data,2) ) ];
end
figure(1),hold on, plot(data(1,:),'r'), plot(regData(1,:)), title
('regressed (b) and raw(r) ')
legend('raw','regressed')
xlabel('samples')
ylabel('Intensity')
and here is the reslts:
as you can see the regression doesnt really work. Do you have any idea why and how I can fix it?
Thanks a lot and kind Regards
Check if regData has any data in the first column. This can also happen if one data is several magnitudes higher or lower. It becomes negligible in the same chart. I tried your code with dummy data and it works.
If what you are looking for is just a visual representation of regressions, and you don't need to store/process data, I suggest you to use the function plotregression (https://it.mathworks.com/help/nnet/ref/plotregression.html).

"Mixed integer class inputs are not supported" Error

I am working on a project in Matlab and i have to use the gradient function. Following is my code snippet:
im=imread('A.jpg'); //Reads image File
[Ix,Iy]=gradient(rgb2gray(im));
I am Getting the Following error.
Error using bsxfun
Mixed integer class inputs are not supported.
Error in gradient (line 68)
g(2:n-1,:) = bsxfun(#rdivide,(f(3:n,:)-f(1:n-2,:)),h);
I am not able to understand why this error is showing up and how to resolve it.
PS: I know there are many questions posted related to same error but they are due to different causes. I have gone through them but am not to solve my problem.
load an image.
Use rgb2grey if necessary.
Use im2double
Use gradient function, i.e., [fx,fy]=gradient(image)
Use matlab function quiver(fx,fy) to get the result displayed.
Ahsan Latif
You should try [Ix, Iy] = gradient(double(rgb2gray(A))). Or alternatively, as Daniel suggests, use imgradient.

MATLAB: Error in fig2texPS

I want to use fig2texPS to export plots from MATLAB to LaTeX. I copied the the script to D:\Eigene Dokumente\MATLAB\fig2TexPS and added this folder as a path in MATLAB. Unfortunately, I receive the following error:
>> fig2texPS()
Undefined function 'find' for input arguments of type 'matlab.graphics.chart.primitive.Line'.
Error in fig2texPS (line 526)
lsh = double(find(handle(lshandles),'-class','graph2d.lineseries')); % find plots
PS: I use a version of the script which was updated in order to work with pdtlatex (http://pastebin.com/xK6KxxBT) that I found in the MATLAB Central File Exchange. The same error also occurs when I use the original script.
This might not be the answer you are looking for, but there is the marvelous matlab2tikz that does the job of conversion of figures quite nicely, which you could use as an alternative to fig2texPS.
I also use the function fig2texPS.m and it works very well. It might be an answer for your question to use an older version of Matlab. I am using 2013b and it works. While I have tried this function with Matlab 2015a, I was getting the same error message.
I hope my answer helps you with your problems.

Integrate a function in Matlab

I know this is a novice question, but I'm new at Matlab and am trying to integrate a function for n=0, n=1, etc.. This is my code so far:
function x = t^n*(t+5)^-1
int(x,t=0..1)
And I keep on getting this error:
Error: File: a02_IX.m Line: 1 Column: 15
Unexpected MATLAB operator.
Does anyone know what this could be?
Thank you!
Try writing it this way:
function x = t^n/(t+5) int(x,t=0..1)
I think raising the term in parentheses to the -1 power reads badly. Maybe MATLAB is confused, too.
What's the value for n? Don't you need to specify that?
It helps to know the answer before you start. This is easy to integrate analytically.
The function looks like this for n=2:
http://www.wolframalpha.com/input/?i=plot+t%5E2%2F%28t%2B5%29+t%3D0..1
Here's the integral, both indefinite and definite:
http://www.wolframalpha.com/input/?i=integrate+t%5E2%2F%28t%2B5%29+from+t%3D0+to+1