ํ•„ํ„ฐ ์ง€์šฐ๊ธฐ
ํ•„ํ„ฐ ์ง€์šฐ๊ธฐ

how to curve fit a sine wave to some data

์กฐํšŒ ์ˆ˜: 21 (์ตœ๊ทผ 30์ผ)
Matt Thomas
Matt Thomas 2023๋…„ 8์›” 12์ผ
๋Œ“๊ธ€: Matt Thomas 2023๋…„ 8์›” 13์ผ
I have been using a open source software package called openFAST to generate some binary files of wind turbine simulations. I then use MATLAB to view the results of the 5MW_Land_DLL.outb files generated by openFAST using the following code:
%% Run this command first
%% Read a binary output file
% Read file
outbfile = '5MW_Land_DLL_WTurb.outb';
[Channels, ChanName, ChanUnit, FileID, DescStr] = ReadFASTbinary(outbfile);
time = Channels(:,1);
This code organizes the data into the matrices etc. like in the image below:
I then use the plot function to generate a graph:
%%CHange the plot number to reflect the parameter in channel names matrix generated from above command.
% Plot Channel 34
iChan=34
figure()
plot(time, Channels(:,iChan))
xlabel('Time (s)')
ylabel([ChanName(iChan) ChanUnit(iChan)])
That looks like :
What I would like to do now is curve fit a sine wave to this plot above so I can get the frequency, the amplitude, phase, and the equation from it.
Is this possible to do?
I have zero experience in MATLAB. The above code was given to me. ๐Ÿ™‚ I am not a coder at all.
Thanks
  ๋Œ“๊ธ€ ์ˆ˜: 7
Matt Thomas
Matt Thomas 2023๋…„ 8์›” 13์ผ
ok, ill try to figure that out. ill google the syntax. thank you much
Matt Thomas
Matt Thomas 2023๋…„ 8์›” 13์ผ
i keep getting an error when using fft.
y=fft( time, Channels(:,iChan))
FFT length must be a nonnegative integer scalar.
thanks

๋Œ“๊ธ€์„ ๋‹ฌ๋ ค๋ฉด ๋กœ๊ทธ์ธํ•˜์‹ญ์‹œ์˜ค.

์ฑ„ํƒ๋œ ๋‹ต๋ณ€

Matt J
Matt J 2023๋…„ 8์›” 12์ผ
One way, assuming you have the Curve Fitting Toolbox:
fobj = fit( time, Channels(:,iChan) ,'sin1')
  ๋Œ“๊ธ€ ์ˆ˜: 7
Matt Thomas
Matt Thomas 2023๋…„ 8์›” 13์ผ
ํŽธ์ง‘: Matt Thomas 2023๋…„ 8์›” 13์ผ
well, it plots it and works but for sure NOT the results i had in my head haha. I thought it would be more of a tighter and faster sin wave but its nice and slow haha.
when i look at my graph i see a tighter sin wave IE from time 0-15 seconds is a peak, then 15-25 is another peak, and 25-35 is another.
thanks for this. ill see if i can use the data to help me out
Matt Thomas
Matt Thomas 2023๋…„ 8์›” 13์ผ
this is what i saw in my head haha

๋Œ“๊ธ€์„ ๋‹ฌ๋ ค๋ฉด ๋กœ๊ทธ์ธํ•˜์‹ญ์‹œ์˜ค.

์ถ”๊ฐ€ ๋‹ต๋ณ€ (0๊ฐœ)

์นดํ…Œ๊ณ ๋ฆฌ

Help Center ๋ฐ File Exchange์—์„œ Correlation and Convolution์— ๋Œ€ํ•ด ์ž์„ธํžˆ ์•Œ์•„๋ณด๊ธฐ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by