필터 지우기
필터 지우기

Change intensity of zplane figure

조회 수: 11 (최근 30일)
Konstantinos
Konstantinos 2023년 11월 3일
댓글: Konstantinos 2023년 11월 4일
Hello everyone,
I was trying to change the line-width of the zplane figure in order to make it more visible.I tried the set command but it didnt work.How can i fix it so it can work?
Thanks in advance.
This is my code so far:
function Lab2_Part_One
close all;
clearvars;
% Create directory if it doesn't exist
directory = 'Ask1';
if ~isfolder(directory) %For versions before R2017b use exist
% instead of is folder
mkdir(directory);
end
% Given transfer function
num = [0.2 0]; % Numerator coefficients
den = [1 -0.7 -0.18]; % Denominator coefficients
w = -pi:pi/128:pi; % Frequency range
% Function calls
plotPoleZeroPlot(num, den, directory);
end
function plotPoleZeroPlot(num, den, directory)
% Function to plot the pole-zero plot
figure;
h = zplane(num, den);
% Set the properties for poles (red lines)
set(h_poles, 'Color', 'green', 'LineWidth', 2); % Change color to green and line width
% Set the properties for zeros (blue lines)
set(h_zeros, 'Color', 'magenta', 'LineWidth', 1.5); % Change color to magenta and line width
% Redraw the unit circle with the desired linewidth
hold on;
t = 0:0.01:2 * pi; % Define points for the unit circle
plot(cos(t), sin(t), 'Color', [0 0.4470 0.7410], 'LineWidth', 1); % Plot the unit circle with the desired linewidth
%grid on;
title('Pole-Zero Plot of the Transfer Function H(z)');
% Save the pole-zero plot in the specified directory as a PNG file
filename = fullfile(directory, 'pole_zero_plot.png');
saveas(gcf, filename);
end

채택된 답변

Star Strider
Star Strider 2023년 11월 3일
Changing the properties requirees a bit of handle-spelunking, however it is possible.
Try this —
[z,p,k] = ellip(4,3,30,200/500);
figure
zplane(z,p)
grid
title('4th-Order Elliptic Lowpass Digital Filter')
figure
hzp = zplane(z,p);
grid
title('4th-Order Elliptic Lowpass Digital Filter')
getgca = get(gca);
Kids = getgca.Children;
Kids(2).Color = 'g';
Kids(2).LineWidth = 2;
Kids(3).Color = 'm';
Kids(3).LineWidth = 1.5;
% figure
% hold on
% plot(Kids(1).XData, Kids(1).YData, ':')
% plot(Kids(2).XData, Kids(2).YData, 'xg', 'LineWidth',2)
% plot(Kids(3).XData, Kids(3).YData, 'om', 'LineWidth',1.5)
% hold off
% axis([[-1 1]*1.5 [-1 1]*1.25])
% grid
The zplane function creates 3 different line objects, and once they are found, changing their properties is straightforward.
.
  댓글 수: 7
Star Strider
Star Strider 2023년 11월 4일
Thank you!
It is easier, however it appears that the line objects do not always appear in the same order, for whatever reason. If you want them to all be the same colours and sizes, the first solution is easier. If you want them to be specifically different, the strcmp approach is necessary. It all depends on what you want.
Konstantinos
Konstantinos 2023년 11월 4일
Thanks.I will keep in mind

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

추가 답변 (0개)

카테고리

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

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by