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

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.

댓글을 달려면 로그인하십시오.

답변 (1개)

Robert
Robert 2016년 3월 10일

0 개 추천

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)

카테고리

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

질문:

2016년 3월 10일

댓글:

2016년 3월 10일

Community Treasure Hunt

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

Start Hunting!

Translated by