필터 지우기
필터 지우기

Symbolic function with constant value - MATLAB

조회 수: 8 (최근 30일)
Juan
Juan 2016년 5월 14일
답변: Image Analyst 2016년 5월 14일
Hello everyone. I'm trying to plot different values of a function:
z = (1+s)/(-1+s^2)
with s from 1 to 100. I mean:
syms z
syms s
for s=1:100
plot(z)
end
But that doesn't work!! It always give me the answer: z=(1+s)/(1+s^2)
How can I do to plot the different values of z? I mean: z(1) = 2/2 = 1, z(2) = 3/4 = 0.75 , ...
Thanks!

답변 (1개)

Image Analyst
Image Analyst 2016년 5월 14일
Don't use syms - use actual numbers:
s = 1 : 100;
z = (1 + s) ./ (-1+s .^ 2)
plot(s, z, 'b*-', 'LineWidth', 2, 'markerSize', 13);
grid on;
xlabel('s', 'FontSize', 15);
ylabel('z', 'FontSize', 15);

카테고리

Help CenterFile Exchange에서 Conversion Between Symbolic and Numeric에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by