DSP first toolbox for matlab

조회 수: 14 (최근 30일)
lee
lee 2012년 2월 2일
댓글: Walter Roberson 2024년 9월 6일
Hi...
when i use zvect function to plot the vector in matlab, i receive this error:
>> z = -1 + 6*i
z =
-1.0000 + 6.0000i
>> zvect (z)
??? Error using ==> plot
Error in color/linetype argument
Error in ==> ZVECT at 77
h = plot(real([zFrom;zTo]), imag([zFrom;zTo]), linetype, real(tt), imag(tt),
linetype );
and a plot window pop up in blank means no vector appearance.
plz guide me how to resolve this issue. I am using Matlab 7.12.0 (R2011a)
Thanks
function hv = zvect(zFrom, zTo, arg3, arg4)
%ZVECT Plot vectors in complex z-plane from zFrom to zTo
%
% usage: HV = zvect(zFrom, <zTo>, <LTYPE>, <SCALE>)
%
% Z: is a vector of compplex numbers; each one will be
% displayed as an arrow emanating from the origin.
% LTYPE: string containing any valid line type (see PLOT)
% SCALE: controls size of arrowhead (default = 1.0)
% (order of LTYPE and SCALE args doesn't matter)
% HV: output handle from graphics of vector plot
%
% ** With only one input vector: zvect(Z)
% displays Z as arrows emanating from the origin.
% ** If either zFrom or zTo is a scalar all vectors will
% start or end at that point.
%
% See also ZCAT, PLOT, COMPASS, ROSE, FEATHER, QUIVER.
% based on the MATLAB toolbox function COMPASS
zFrom = zFrom(:).';
scale = 1.0;
vv = version;
if( vv(1)=='5')
linetype = 'b-';
else
linetype = 'w:-'; %<--- WHITE is NOT good in v5
end
if( nargin==1 )
zTo = zFrom; zFrom = 0*zTo;
elseif( nargin == 2 )
if( isstr(zTo) )
linetype = zTo; zTo = zFrom; zFrom = 0*zTo;
elseif( isempty(zTo) )
zTo = zFrom; zFrom = 0*zTo;
elseif( length(zTo)==1 )
zTo = zTo*ones(size(zFrom));
end
elseif( nargin==3 )
if( isstr(arg3) ), linetype = arg3;
else, scale = arg3;
end
elseif( nargin == 4 )
if( isstr(arg3) ), linetype = arg3; scale = arg4;
else, scale = arg3; linetype = arg4;
end
end
zTo = zTo(:).';
jkl = find( ~isnan(zTo-zFrom) );
if( length(jkl)==0 ), error('cannot plot NaNs'), end
zTo = zTo(jkl);
zFrom = zFrom(jkl);
if( length(zFrom)==1 )
zFrom = zFrom*ones(size(zTo));
elseif( length(zTo)==1 )
zTo = zTo*ones(size(zFrom));
end
if length(zFrom) ~= length(zTo)
error('ZVECT: zFrom and zTo must be same length.');
end
tt = [zFrom,zTo];
[zmx,jkl] = max(abs(tt));
figsize = max(abs(tt-tt(jkl)));
arrow = scale*([-1; 0; -1] + sqrt(-1)*[1/4; 0; -1/4]);
dz = zTo - zFrom;
dzm = abs(dz);
zmax = max(dzm);
zscale = mean([zmax,figsize]);
scz = 0.11 + 0.77*(dzm/zscale - 1).^6;
tt = [ ones(3,1)*(zTo) + arrow*(scz.*dz) ];
next = lower(get(gca,'NextPlot')); %--Ver 4.1
isholdon = ishold; %--Ver 4.1
h = plot(real([zFrom;zTo]), imag([zFrom;zTo]), linetype,...
real(tt), imag(tt), linetype );
num_zzz = length(zFrom);
for kk = 1:num_zzz
kolor = get(h(kk),'color');
set(h(kk+num_zzz), 'color',kolor);
end
axis('equal'); %--Ver 4.1
if ~isholdon; %--Ver 4.1
set(gca,'NextPlot',next); %--Ver 4.1
end; %--Ver 4.1
if nargout > 0
hv = h;
end

채택된 답변

Walter Roberson
Walter Roberson 2012년 2월 3일
Replace the 'w:-' with 'w:'
  댓글 수: 3
Marshall
Marshall 2024년 9월 5일
편집: Marshall 2024년 9월 5일
I'm having the same issue, I made the change to 'w:' and now no errors pop up but still nothing gets plotted.
Walter Roberson
Walter Roberson 2024년 9월 6일
If you run on MATLAB Online or MATLAB Answers, then the default background color for plotting is white, and using a white marker does not show up against a white background. You see results if you change it to something like 'r:'

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

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by