how to clear the warning negative data ignored?
이전 댓글 표시
clc; clear all; close all; w=18; p=103; n=2; q21=0.07; q20=0.91; q22=0.0071; fid=fopen('proj12.dat','w'); for ks=65:10:100 ks pe=0; for k=0:1:w-1 c=((factorial(w-k))/factorial(w))*(factorial(w-1)/factorial(w-k-1)); for y=0:1:w-2 z=((factorial(w-y))/factorial(w))*(factorial(w-2)/factorial(w-y-2)) d=q20+(c*(q21))+(z*(q22)); e=(d^((ks)-1)); for j=0:1:w pe1=(factorial(w)/((factorial(w-j))*factorial(j))); x=pe1*e; pe2=((-1)^j)*x; pe=pe+pe2; end end
end
pez=pe/2
fprintf(fid,'%2d %5.3e \n',ks,pez);
end
fclose(fid);
while plottig the graph for above program i had a warning that negative data ignored....how to clear it?
답변 (2개)
Matt Tearle
2011년 3월 7일
Use lastwarn to find the identifier of the warning message, then use warning to turn it off. Once you know the identifier, you can put the warning command at the beginning of your script.
Example:
x = linspace(-1,1);
semilogy(x,x.^3)
% I get a warning message
[~,foo] = lastwarn
% Now I know the identifier: 'MATLAB:Axes:NegativeDataInLogAxis'
warning('off','MATLAB:Axes:NegativeDataInLogAxis')
semilogy(x,x.^5)
Walter Roberson
2011년 3월 7일
0 개 추천
Better yet, plot max(0,x) to force there to be no negative data. (The 0's will be a problem on the log plot, though...)
카테고리
도움말 센터 및 File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!