Replace a syms command
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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.
0 commentaires
Réponses (1)
Robert U
le 11 Fév 2022
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
0 commentaires
Voir également
Catégories
En savoir plus sur Conversion Between Symbolic and Numeric dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!