How to implement custom function in Flight Log Analyzer
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]);
endI 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 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 uav, flightloganalyzer, fft, function MATLAB Answers — New Questions