Hi,
I am working on signal processing where I am importing points from a text file. Recently MatLab has started posting all of the points in the command window before moving forward. I have two versions of MatLab and they both do this. Additionally, I can only run the code once, if I try a second time it displays points in the command window but does not execute any more of the code. I'm not sure if this is a preference or debugging option I have accidentally selected, but it's quite time consuming to have to restart MatLab every time.
Here is my code, if it helps:
clear all; close all;% Sampling frequency.
fs = 5000000;% Load data, determine size and time base.
load A28316.txt;[n,p] = size(A28316);t = 1:n;ts = linspace(0,0.5,2500000);% Define sensor data and individual sensors.
sensors = A28316(:,1:end);sensor1 = A28316(:,1);sensor2 = A28316(:,2);% Mean value of signal.
m1 = mean(sensor1);m2 = mean(sensor2);% Set mean to zero, removing DC component.
DC1 = sensor1 - m1;DC2 = sensor2 - m2;% Transpose to row vector for 'for' loop.
m = DC1';me = DC2';% Set all points except selected to zero, for both signals.
for i = 1:1:4999 m(:,i) = 0;endfor i = 15001:1:2500000 m(:,i) = 0;endfor i = 1:1:4999 me(:,i) = 0;endfor i = 15001:1:2500000 me(:,i) = 0;end% FFT
o1 = length(m);o2 = length(me);tl1 = pow2(nextpow2(o1)); % Transform length
tl2 = pow2(nextpow2(o2));y1 = fft(m,tl1); % DFT
y2 = fft(me,tl2); f1 = (0:tl1-1)*(fs/tl1); % Frequency range
f2 = (0:tl2-1)*(fs/tl2);p1 = y1.*conj(y1)/tl1; % Power of the DFT
p2 = y2.*conj(y2)/tl2;plot(f1,p2,'r');hold onplot(f1,p1,'b');hold offxlabel('Frequency');ylabel('Power');legend('sensor2','sensor1');title('FFT Power Spectrum of Two Signals, Lead Break on Testing Cylinder');
I don't believe I have left out any semi-colons… If anyone can help me out that would be great. Many thanks,
Jonny
Best Answer