clear;
clc;
syms 'j'
y1 = 7 .* (-0.2).*j.*cos(7.*j + 3);
y2 = 5 .* exp(-1.1).*j.*tan(3.*j - 1);
fplot(y1, [0 30]);
hold on;
fplot(y2, [0 30]);
title({'Graph'})
xlim([0 30]);
ylim([-6 6]);
xlabel('Time, t(s)');
ylabel('Amplitude y1, y2 (mm)');
legend('y1(t) = 63^(-0.2)tsin(7t+3)', 'y2(t) = 4e^(-0.1)tsin(3t-1)');
saveas(gcf, 'Graph.png');
I'm trying to replace the syms 'j' command with numerical values for x that would replace the j's in my functions. I can't seem to get the same graph with what I've tried.

답변 (1개)

Robert U
Robert U 2022년 2월 11일

0 개 추천

Hi Sarah Gomez,
I am not quite sure whether I understood you question correctly, but removing the syms j command is not sufficient since "j" is pre-defined as imaginary unit.
If you want to get rid of the symbolic representation, you can use anonymous functions. That would allow you to keep the rest of the code.
Your legend does not represent your used formulae correctly, that is why you could have a look at func2str().
clear;
clc;
y1 =@(x) 7 .* (-0.2).*x.*cos(7.*x + 3);
y2 =@(x) 5 .* exp(-1.1).*x.*tan(3.*x - 1);
fplot(y1, [0 30]);
hold on;
fplot(y2, [0 30]);
title({'Graph'})
xlim([0 30]);
ylim([-6 6]);
xlabel('Time, t(s)');
ylabel('Amplitude y1, y2 (mm)');
legend(func2str(y1),...
func2str(y2),'FontSize',12);
Kind regards,
Robert

카테고리

도움말 센터File Exchange에서 Mathematics에 대해 자세히 알아보기

태그

질문:

2022년 2월 11일

답변:

2022년 2월 11일

Community Treasure Hunt

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

Start Hunting!

Translated by