0
%use fitobject = fit([x,y],z,fitType)creates a surface fit to the data in vectors x, y, and z.
fitobject = fit([t,omega_0],z,fitType);
fittype('A*cos(omega_0*t+phi)','problem',{'A','phi'},'options',fo) %fo was previously defined & a and b are coefficients and n is a problem-dependent parameters

%__________________________________________________________________________
%phi is defined below by the angular function:
xdft = fft(t); % Obtain the DFT
camp = 2/length(t)*xdft(t); %this is FFT at any point t
angle(camp) % gives the phase at a certain point, but how to do it at the
%represents as a function in all places, I have no idea
abs(camp) % amplitude i.d.F A=abs(camp)
%__________________________________________________________________________

% problem = Problem-dependent (fixed) parameter names, i.e. a &
% phi is the zero phase angle at the time t=0
% options = Fit options, specified as the comma-separated pair consisting of 'options' and the name of a fitoptions object.

% Example: 'coefficients',{'a1','a2'}

Goal: - run this code -get value for coefficient A & phi (which is the phase shift)

I defined all variables & imported the data table as column vectors (401x1 matrices each). Im solely working in the x-y-plane, so z=0 in all rows. Alternatively I could fit the surface with Anonymous Functions, but I think strongly that that won't solve/ improve the real problem of running the code.

3
  • 2
    Certainly its not working for us because e.g. t is not defined, among other things. Commented Nov 3, 2023 at 17:00
  • Please read minimal reproducible example. We cannot see what you see, because we don’t have your data. So update the code to be self-contained, so we can run it. Also, please copy-paste the error message into your post, so we know what problem you might be having. “It doesn’t run” is not a great description of your problem. Commented Nov 3, 2023 at 18:33
  • t is a column vector which is imported in the workspace Commented Nov 6, 2023 at 17:02

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.