Why does my code produce a different graph every time I run it?
Mostrar comentarios más antiguos
I am currently trying to produce a graph of acceleration. I initially had 66000 samples, and cropped it to 20001:66000 as this is where the interesting data is. There are also 3 other sensors with the data in a matrix, acceleration is the last column in said matrix. To perform an analysis I wished to average every 460 points into 1, to reduce the white noise on an fft. The code for this section was provided in a separate question and I am unsure whether it is correct. After the averaging I am trying to plot this graph (altering number of samples to a time domain). However, every time I run my code the graph produced keeps changing and I cannot figure out why. Any help would be greatly appreciated. Code is as below.
LongTestArray = table2array(LongTest);
A = LongTestArray(20001:66000, 1:4);
M = mean(A);
A(:,3) = A(:,3) - M(:,3);
A(:,4) = A(:,4) - M(:,4);
B = A;
B = randi(9, 46000, 4); %Create Matrix
Ar = reshape(B, [], 4, 4600); % Reshape
% A_RMS = sqrt(mean(Br.^2, 3)); % Calculate RMS
X=Ar(:,4);
f = 43.5 ; % reduced from sample rate of 20000 due to averaged results
samples = 0:size(X, 1)-1 ;
t = samples/f ;
%plot column 1
plot(t, X(:, 1) ) grid on ;
hold on ;
title('Low Frequency Accelerometer Test 1')
xlabel('Time (s)') % x-axis label
ylabel('Voltage (V)')
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Graph and Network Algorithms en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!