how to distinguish between four zeros in matlab plotting
5 次查看(过去 30 天)
显示 更早的评论
I ploted the zeros of the function f(z), where z is a complex number and its rootes are complex numbers. for example
When f(z) has 4 zeros move in the complex plane with time t. How can I write the name of these zeros on their graph to show the movement of each zero in the complex plane. (I mean How do I distinguish zeros from each other?) on the graph.
Thank you very much
0 个评论
采纳的回答
Voss
2022-3-27
Something like this?
% get some complex numbers, z:
f = [1 2 3 4 5];
z = roots(f)
% plot z on the complex plane and label them as 'Zero #1', etc.:
figure();
x = real(z);
y = imag(z);
for ii = 1:numel(z)
plot(x(ii),y(ii),'ko');
hold on
text(x(ii),y(ii),sprintf('Zero #%d',ii), ...
'VerticalAlignment','top','HorizontalAlignment','center');
end
2 个评论
Voss
2022-4-11
@Aisha Mohamed Because the "\zeta" is part of the first argument to sprintf (i.e., the string format specification), the backslash will be treated as a special character for sprintf. In order to avoid that and just have the backslash be a backslash, so that it is correctly interpreted as "\zeta" by the text function, use a double-backslash to tell sprintf to ignore the backslash. It looks like this:
% get some complex numbers, z:
f = [1 2 3 4 5];
z = roots(f);
% plot z on the complex plane and label them as 'Zero #1', etc.:
figure();
x = real(z);
y = imag(z);
for ii = 1:numel(z)
plot(x(ii),y(ii),'ko');
hold on
text(x(ii),y(ii),sprintf('\\zeta #%d',ii), ...
'VerticalAlignment','top','HorizontalAlignment','center');
end
Here's the result from sprintf in both cases, for your reference:
sprintf('\zeta #%d',3) % \z doesn't mean anything to sprintf
sprintf('\\zeta #%d',3) % \\ becomes \ (so that \\zeta becomes \zeta, which is then used in text())
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Graphics Object Identification 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!