Calculate the derivative of a segment function
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
a = 0.6;
b = 0.1;
x = linspace(0,3*a,181);
% Here is my segment function
% How can i calculate its derivative
function [yu] = up(x1,a,b)
yu = zeros(size(x1));
for k = 1 : length(yu)
x = x1(k);
if x > 0 && x <= a;
% x is in the range [0, a]
yu(k) = (b^2 - ((b^2)/(a^2)).*(x-a).^2).^(1/2);
else x > a && x < 3*a;
% x is in the range [a, 3*a]
yu(k) = (((b/(4*a^3)).*x.^(3)) - ((3*b)/(2*a^2)).*(x.^2) + (9*b)/(4*a).*x);
end
end
end
Réponses (1)
VBBV
le 2 Fév 2022
a = 0.6;
b = 0.1;
x = linspace(0,3*a,181);
Y = up(x,a,b); %
plot(x,Y)
% Here is my segment function
% How can i calculate its derivative
function [yu] = up(x1,a,b)
yu = zeros(size(x1));
for k = 1 : length(yu)
x(k) = x1(k);
if x(k) > 0 && x(k) <= a;
% x is in the range [0, a]
yu(k) = (b^2 - ((b^2)/(a^2)).*(x(k)-a).^2).^(1/2);
else x(k) > a && x(k) < 3*a;
% x is in the range [a, 3*a]
yu(k) = (((b/(4*a^3)).*x(k)^(3)) - ((3*b)/(2*a^2)).*(x(k)^2) + (9*b)/(4*a)*x(k));
end
end
yu = gradient(yu)./gradient(x); % derivative using gradient
end
you can use diff as well to check the derivative property
2 commentaires
Voir également
Catégories
En savoir plus sur Linear Algebra 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!
