how to curve fit a sine wave to some data
์กฐํ ์: 21 (์ต๊ทผ 30์ผ)
์ด์ ๋๊ธ ํ์
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:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1455897/image.png)
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 :
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1455902/image.png)
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 J
2023๋
8์ 12์ผ
One way, assuming you have the Curve Fitting Toolbox:
fobj = fit( time, Channels(:,iChan) ,'sin1')
๋๊ธ ์: 7
์ถ๊ฐ ๋ต๋ณ (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!