Command Window Suppression Not Working Correctly?
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Jonathan Fairfoull
am 9 Mär. 2016
Bearbeitet: Jonathan Fairfoull
am 10 Mär. 2016
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;
end
for i = 15001:1:2500000
m(:,i) = 0;
end
for i = 1:1:4999
me(:,i) = 0;
end
for 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 on
plot(f1,p1,'b');
hold off
xlabel('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
0 Kommentare
Akzeptierte Antwort
Walter Roberson
am 9 Mär. 2016
Try changing
load A28316.txt;
to
A23816 = load('A28316.txt');
1 Kommentar
Weitere Antworten (1)
Jan
am 9 Mär. 2016
You can use the debugger to identify the line, which causes the output: Set a breakpoint in the code and step through the program line by line until the output appears.
This will help aou also to find out, why the code does not run the 2nd time you call it - which seems to be a strange problem.
Note: This is much faster instead of the loops:
m(:,1:4999) = 0;
m(:,15001:2500000) = 0;
me(:,1:4999) = 0;
me(:,15001:2500000) = 0;
1 Kommentar
Siehe auch
Kategorien
Mehr zu Bartlett finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!