DSP first toolbox for matlab

2 ビュー (過去 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 Center および File ExchangeMATLAB についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by