need a help doing simple code

14 visualizzazioni (ultimi 30 giorni)
Geonhee LEE
Geonhee LEE il 26 Lug 2016
Commentato: Thorsten il 27 Lug 2016
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...?

Risposta accettata

Thorsten
Thorsten il 26 Lug 2016
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 Commenti
Geonhee LEE
Geonhee LEE il 27 Lug 2016
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 il 27 Lug 2016
I do not have the syms toolbox, so I cannot give further advice.

Accedi per commentare.

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by