need a help doing simple code

조회 수: 13 (최근 30일)
Geonhee LEE
Geonhee LEE 2016년 7월 26일
댓글: Thorsten 2016년 7월 27일
Hello guys. I have some problem in below code.
First of all I want to input 4 variables(W, L, H, R).
And then q,a,b are defined as below.
q=H/L, a=W/q, b=(W*(1-R)/(2*q));
And then fuction f(X), g(X), h(x), p(x) are defined as below
f(x)=sqrt(a*x+b^2)-x-b
h(x)=W*0.9-x;
and the intersection of f(x) and h(x) is defined as (m,n)
and then g(x)=f(t)/t*x , (t,f(t)) is a point on the f(x)
p(x)=(f(t)-n)/(t-m)*(x-m)+n
now, A(t) is defined as below.
A(t)=integral of (f(x)-g(x)) at (0<x<t) + integral of (f(x)-p(x)) at (t<x<m)
and I want to show the value of t when A'(t)=0
Can you guy help me...?

채택된 답변

Thorsten
Thorsten 2016년 7월 26일
To learn Matlab you can start by something like
function y = myfunction(W, L, H, R)
q=H/L;
a=W/q;
b=(W*(1-R)/(2*q));
and so on and then ask more specific questions if you have further problems. I might be hard to find someone that does your homework for you, and it wouldn't help you in the long run.
  댓글 수: 2
Geonhee LEE
Geonhee LEE 2016년 7월 27일
thank you for answering my question. As you said, I set up the functions and try to solve the integral but a error has occured.
my code :
>> syms L;
>> syms W;
>> syms a;
>> syms q;
>> syms n;
>> syms m;
>> syms R;
>> q = H./L;
a = W./q;
b = (W*(1-R)/(2*q));
m = (0.01*(81.0*W^2 + 180.0*b*W))/a;
>> n=sqrt(a*m+b^2)-m-b;
>> syms x;
>> f=sqrt(a*x+b^2)-x-b;
>> h=W*0.9-x;
>> m=(0.01*(80.1*W^2+180.0*b*W)/a);
>> n=sqrt(a*m+b^2)-m-b;
>> syms t;
>> f=@(x) sqrt(a*x+b^2)-x-b;
>> g=@(x,t) (sqrt(a*t+b^2)-t-b)/t*x;
>> p=@(x,t) ((sqrt(a*t+b^2)-t-b)-n)/(t-m)*(x-m)+n;
>> a=integral (f,0,m)-integral (g,0,t)-integral(p,t,m);
and here, I want to calculate the total integral, but some error has occured..
how do I solve it?
thank you.
Thorsten
Thorsten 2016년 7월 27일
I do not have the syms toolbox, so I cannot give further advice.

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

추가 답변 (0개)

Community Treasure Hunt

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

Start Hunting!

Translated by