How to implement custom function in Flight Log Analyzer

2 vues (au cours des 30 derniers jours)
Mckenzie Turpin
Mckenzie Turpin le 14 Août 2024
Commenté : Walter Roberson le 15 Août 2024
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 commentaire
Umar
Umar le 14 Août 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

Connectez-vous pour commenter.

Réponses (1)

Walter Roberson
Walter Roberson le 15 Août 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 commentaires
Mckenzie Turpin
Mckenzie Turpin le 15 Août 2024
I am not sending this to a custom made app, it would be sent to an app that is imbedded in the UAV Toolbox with MATLAB. So simply assigning it to an axis to be plotted onto would not work as i do not know the axis name.

Connectez-vous pour commenter.

Community Treasure Hunt

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

Start Hunting!

Translated by