How to implement custom function in Flight Log Analyzer
Ältere Kommentare anzeigen
I am trying to create a custom function within the Flight Log Analyzer app in the UAV Toolbox, and I am getting errors no matter what I try. I am simply trying to plot a Fast-Fourier Transform of Accel and Gyro data. Below is an example of a function I wrote that works on its own, but I can not get it to work within the app. I am wondering what the function sturcture is that the app is looking for. I see what is on the pop up window when you go to create the function, but even when I try creating more arguments for the function I get index mismatch errors. An example of a function that can be passed into the app would be very helpful.
(in this example, "signalData" would be ACC_0 from the workspace file)
function afft = ArdupilotFFT(singalData)
Fs = 2000;
L = length(singalData);
L2 = floor(L/2);
f0 = Fs/L*(0:L2-1);
X0 = fft(singalData(:,5));
X0 = 10*log10(abs(X0(1:L2)));
Y0 = fft(singalData(:,6));
Y0 = 10*log10(abs(Y0(1:L2)));
Z0 = fft(singalData(:,7));
Z0 = 10*log10(abs(Z0(1:L2)));
figure('Name','FFT');
%subplot(1,3,1);
semilogx(f0,X0,f0,Y0,f0,Z0)
grid on; xlabel('Frequency (Hz)'); xlim([1,1000]);
end
1 Kommentar
Umar
am 14 Aug. 2024
Hi
Please refer to this documentation for detailed guidelines as mentioned in links below. Please let me know if this helps resolve your problem.
https://www.mathworks.com/help/uav/ug/visualize-custom-flight-log.html
https://www.mathworks.com/help/uav/ref/flightloganalyzer-app.html
Antworten (1)
Walter Roberson
am 15 Aug. 2024
Assuming that the plotting is to be directed to UIAxes3
function afft = ArdupilotFFT(app, singalData)
Fs = 2000;
L = length(singalData);
L2 = floor(L/2);
f0 = Fs/L*(0:L2-1);
X0 = fft(singalData(:,5));
X0 = 10*log10(abs(X0(1:L2)));
Y0 = fft(singalData(:,6));
Y0 = 10*log10(abs(Y0(1:L2)));
Z0 = fft(singalData(:,7));
Z0 = 10*log10(abs(Z0(1:L2)));
ax = app.UIAxes3; %for example
semilogx(ax, f0, X0, f0, Y0, f0, Z0)
grid(ax, 'on');
xlabel(ax, 'Frequency (Hz)');
xlim(ax, [1,1000]);
end
2 Kommentare
Mckenzie Turpin
am 15 Aug. 2024
Walter Roberson
am 15 Aug. 2024
See the link https://www.mathworks.com/help/uav/ug/visualize-custom-flight-log.html as Umar suggested.
Kategorien
Mehr zu Scenario Simulation finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!