Why does plotting nans in 3D cause problems with time and ability to save the plot?

조회 수: 1 (최근 30일)
The following script illustrates my problem - when iFloorRem=0 there is no problem with running the script and when it is finished I can save the graph as a *.eps file. When iFloorRem=1 then it takes significantly longer to run and then a long time to actually produce the graph. While that is happening Matlab is locked up. When the graph has been finally produced it takes an extremely long time to save it during which time Matlab is also locked up. For the problem that I am working on, which is more complicated than the script below, it takes so long that I have not been able to complete the save action. I have to use task manager to shut down Matlab to regain control of the computer. I have a Toshiba Qosmio with the I7 chip.
Here is the script:
% Example Script illustrating effect of plotting nans
close all
clear
iFloorRem=1; % set this to 1 to remove the floor, otherwise set to 0
Fs=44100; % sampling frequency
h=1/Fs; % sampling interval
tMax=1; % duration of sample
t=0:h:tMax; % time grid
nt=length(t);
noKeys=50; % number of sinusoids
y=zeros(noKeys,nt); % reserve some room
f=2; % initial frequency
delF=2; % increment in frequency
%===generate the noKeys sinusoids
for k=1:noKeys
y(k,1:nt)=sin(2*pi*t*f);
f=f+delF;
end
if iFloorRem==1
%=== remove floor
[rr, cc]=size(y);
II=y<0;
y(II)=nan;
end
%===plot the sine waves in 3D
for k=1:noKeys
kp=k*ones(nt,1);
plot3(kp,t,y(k,:),'k')
if k==1
hold
end
end
grid
title('A Bunch of Sinusoids')
zlabel('amplitude')
xlabel('sinusoid number')
ylabel('time (s)')
view(37,82)
  댓글 수: 2
Walter Roberson
Walter Roberson 2014년 2월 9일
Could you experiment with setting the locations to -inf instead of nan ?
David Koenig
David Koenig 2014년 2월 9일
Yes, I tried that suggestion and the performance was pretty much the same. Thanks anyway.

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

답변 (0개)

카테고리

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

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by