Command Window Suppression Not Working Correctly?

조회 수: 3 (최근 30일)
Jonathan Fairfoull
Jonathan Fairfoull 2016년 3월 9일
편집: Jonathan Fairfoull 2016년 3월 10일
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

채택된 답변

Walter Roberson
Walter Roberson 2016년 3월 9일
Try changing
load A28316.txt;
to
A23816 = load('A28316.txt');
  댓글 수: 1
Jonathan Fairfoull
Jonathan Fairfoull 2016년 3월 10일
편집: Jonathan Fairfoull 2016년 3월 10일
Thanks a lot, this worked and let me remove some more unnecessary lines. Cheers, Jonny

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Jan
Jan 2016년 3월 9일
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
Jonathan Fairfoull
Jonathan Fairfoull 2016년 3월 10일
편집: Jonathan Fairfoull 2016년 3월 10일
Thanks for your help, the code is being run in around half the time now :D Cheers, Jonny

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Bartlett에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by