Integral problem cant get it to give me a number

I got an assigment where i have to plot two functions and thereafter use a formula where we integrate the differentiate of the two functions to find the length of the figure, but i cant get it to work, hope you can help me out:
clear, clc
close all, close all hidden
t=linspace(0,2*pi,100);
b=5
X=2*b*cos(t)-b*cos(2*t);
Y=2*b*sin(t)-b*sin(2*t);
plot(X,Y)
clear, clc
syms b, syms t
X=2*b*cos(t)-b*cos(2*t);
Y=2*b*sin(t)-b*sin(2*t);
X1=diff(X);
Y1=diff(Y);
F= @ (x) sqrt((X1).^2+(Y1).^2);
b=5;
L=quadl(F,0,2*pi)

1 comentario

What are you intending to differentiate with respect to? You have two variables in the expression. The Symbolic Toolkit does have rules about which variable has priority, but the rules are not easy to remember and other people reading the code are not likely to know them, so you should be specific about the variable of differentiation in the diff() call.

Iniciar sesión para comentar.

Respuestas (1)

Robert
Robert el 10 de Mzo. de 2016
You should look at the documentation for int, the integration function specific to the Symbolic Toolbox. You will also need subs, which is how you substitute in numeric values for your symbolic variables.
Only your last three lines need to change.
F = sqrt((X1).^2+(Y1).^2);
F = subs(F,b,5);
L = int(F,t,0,2*pi)

Categorías

Más información sobre Symbolic Math Toolbox en Centro de ayuda y File Exchange.

Preguntada:

el 10 de Mzo. de 2016

Comentada:

el 10 de Mzo. de 2016

Community Treasure Hunt

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

Start Hunting!

Translated by