Effacer les filtres
Effacer les filtres

i cant able to plot graph of this cord

2 vues (au cours des 30 derniers jours)
suketu vaidya
suketu vaidya le 8 Nov 2020
Réponse apportée : dpb le 8 Nov 2020
function taska
h = 1;
x = -pi:0.01:pi;
d = 50;
y0 = -1;
c1=(y0-(d^2/(d^2+1)));
y=@(x)c1*exp(-diff(x))+d*(sin(x)/(d^2+1))+d^2*(cos(x)/d^2+1);
plot(x,y(x));
end

Réponses (1)

dpb
dpb le 8 Nov 2020
y=@(x)c1*exp(-diff(x))+d*(sin(x)/(d^2+1))+d^2*(cos(x)/d^2+1);
numel(diff(x)) is one less than numel(x) so the above will fail owing to mismatch in number of elements.
But, since
x=-pi:0.01:pi;
it is so that
diff(x) --> 0.01 % within rounding error
so may as well just write as
dx=0.01;
x=-pi:dx:pi;
exp_dx=exp(-dx);
y=@(x) c1*exp_dx+d*(sin(x)/(d^2+1))+d^2*(cos(x)/d^2+1);

Catégories

En savoir plus sur Graph and Network Algorithms dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by