Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Finding variables that give a specific response.

Status
Not open for further replies.

mm391

Mechanical
Jul 25, 2013
9
I have the following code:

clc
clear all

d1=1.6256;
d2=0.77;
d3=0.815;
b=11;
m=967.44;
Ig=9759.19;
V=73.05555;
rho=1.225;
dCL=10;

a11= (1/m)*(k1+k2);
a12= (1/m)*((k1*d3)-(d3*(k1-k2))-(0.5*dCL*rho*(V^2)*d1*b));

a21= (1/Ig)*(d3*(k2-k1));
a22= (1/Ig)*(d3*(k1+k2)-(0.5*dCL*rho*(V^2)*d1*b)*(d1-d3)-d3);

A1=[0,1,0,0;-a11,0,-a12,0;0,0,0,1;-a21,0,-a22,0];

eig(A1);

A=((a11+a22)/2)
B=((a11*a22)-(a12*a21))

I am trying to find the values of k1 and k2 (between 0 and 7e6) that give the results of B>A^2. There is likely to be multiple values so if I could plot them in to a contour plot of k1 vs k2 then it would help.

Can somebody suggest how this would be possible?
 
Replies continue below

Recommended for you

ittcrpngipyniyg6g.jpg


Cheers

Greg Locock


New here? Try reading these, they might help FAQ731-376
 
My code has actually changed a little:

clc
clear all

%% Set Variables

d1=1.6256;
d2=0.77;
d3=0.815;
b=11;
k1=3000;
k2=100;
m=967.44;
Ig=9759.19;
V=73.05555556;
rho=1.225;
dCL=10;
%% A values

a11= (1/m)*(k1+k2);
a12= (1/m)*((k1*d3)-(k2*(d1-d3))-(0.5*dCL*rho*(V^2)*d1*b));

a21= (1/Ig)*((k1*d3)-(k2*(d1-d3)));
a22= (1/Ig)*((k1*(d3^2))+(k2*((d1-d3)^2)-((0.5*dCL*rho*(V^2)*d1*b)*(d3-d2))));


%% State Space A-Matrix

A1=[0,0,1,0;-0,0,0,1;-a11,-a12,0,0;-a21,-a22,0,0];

%% Eigenvalues
eig(A1)

A=((a11+a22)/2)
B=((a11*a22)-(a12*a21))

and my ranges are now from 0 to 7e3. On a graph I need to plot all the values of k1 and k2 that give the following results:

B < 0
0 < B < A^2
B > A2

Can anon suggest code that would allow me to do it?
 
Sorry I forgot to remove

k1 and k2 form my variables.
 
Well sure, I could write the code, I think it needs a maximum of 7 new lines to do that, and 2 modified ones,but I rather wonder what you'd learn from it.

The question "I need to plot all the values of k1 and k2" itself is ridiculous since there an infinite number of pairs k1 and k2 that will satisfy the relationship. I haven't got that long.



Cheers

Greg Locock


New here? Try reading these, they might help FAQ731-376
 
clc
clear all
close all

%% Set Variables
num_runs=100000;
d1=1.6256;
d2=0.77;
d3=0.815;
b=11;
m=967.44;
Ig=9759.19;
V=73.05555556;
rho=1.225;
dCL=10;
k1=7e3*rand(num_runs,1);
k2=7e3*rand(num_runs,1);


%do a little simple maths, eliminate redundant lines

a11= (1/m).*(k1+k2);
a12= (1/m).*((k1*d3)-(k2*(d1-d3))-(0.5*dCL*rho*(V^2)*d1*b));

a21= (1/Ig)*((k1*d3)-(k2*(d1-d3)));
a22= (1/Ig)*((k1*(d3^2))+(k2*((d1-d3)^2)-((0.5*dCL*rho*(V^2)*d1*b)*(d3-d2))));

A=((a11+a22)/2);
B=((a11.*a22)-(a12.*a21));

%plot the results
plot(k1(B<0),k2(B<0),'b.')
hold on
plot(k1((B > 0)&(A.^2>B)),k2((B > 0)&(A.^2>B)),'g.')
plot(k1(B > A.^2),k2(B > A.^2),'k.')
xlabel('k1')
ylabel(' k2')
legend('B<0','0<B<A^2','B>A.^2','Location','Northwest')

Let me know what your professor thinks.



Cheers

Greg Locock


New here? Try reading these, they might help FAQ731-376
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor