Need help using same equation for multiple data points.
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
JAKE WISNIEWSKI
am 7 Nov. 2021
Kommentiert: JAKE WISNIEWSKI
am 9 Nov. 2021
clear
clc
close all
%%Given Information
L1=[100 6 7];
L2=[40 2 9];
L3=[120 7 3];
L4=[80 9 8];
theta_2=[40 30 85];%theta2 in degrees
OC=[1 1 2];%1 for open 2 for crossed
rp=[0 6 9];
d_a=[0 30 25];%delta angle in degrees
OM2=[25 10 -12];%omega2 in rad/2
AP2=[15 0 5];%alpha 2 in rad/2^2
theta2=theta_2*(pi/180);%convert theta 2 to rad
da=d_a*(pi/180);%convert delta to rad
x_size=3
%%Calculations
for i = 1:x_size
K1=L1(i)/L2(i);
K2=L1(i)/L4(i);
K3=(L2(i)^2-L3(i)^2+L4(i)^2+L1(i)^2)/(2*L2(i)*L4(i));
K4=L1(i)/L3(i);
K5=(L4(i)^2-L1(i)^2-L2(i)^2-L3(i)^2)/(2*L2(i)*L3(i));
A=cos(theta2(i))-K1-K2*cos(theta2(i))+K3;
B=-2*sin(theta2(i));
C=K1-(K2+1)*cos(theta2(i))+K3;
D=cos(theta2(i))-K1+K4*cos(theta2(i))+K5;
E=-2*sin(theta2(i));
F=K1+(K4-1)*cos(theta2(i))+K5;
end

Here is my code and the data I am trying to use. I want to solve for K1-K5 and A-F for p#1-14. I have attempted to do only a sample and then the first two rows of data but I can only get it to solve for the sample data and it wont calculate for the first two rows. I thought I should use the x_size but it is not working. Can someone please help me to figure out how I can get my code to run for all of the data points?
0 Kommentare
Akzeptierte Antwort
Walter Roberson
am 8 Nov. 2021
clear
clc
close all
%%Given Information
L1=[100 6 7];
L2=[40 2 9];
L3=[120 7 3];
L4=[80 9 8];
theta_2=[40 30 85];%theta2 in degrees
OC=[1 1 2];%1 for open 2 for crossed
rp=[0 6 9];
d_a=[0 30 25];%delta angle in degrees
OM2=[25 10 -12];%omega2 in rad/2
AP2=[15 0 5];%alpha 2 in rad/2^2
theta2=theta_2*(pi/180);%convert theta 2 to rad
da=d_a*(pi/180);%convert delta to rad
x_size=3
%%Calculations
for i = 1:x_size
K1=L1(i)/L2(i);
K2=L1(i)/L4(i);
K3=(L2(i)^2-L3(i)^2+L4(i)^2+L1(i)^2)/(2*L2(i)*L4(i));
K4=L1(i)/L3(i);
K5=(L4(i)^2-L1(i)^2-L2(i)^2-L3(i)^2)/(2*L2(i)*L3(i));
A(i)=cos(theta2(i))-K1-K2*cos(theta2(i))+K3;
B(i)=-2*sin(theta2(i));
C(i)=K1-(K2+1)*cos(theta2(i))+K3;
D(i)=cos(theta2(i))-K1+K4*cos(theta2(i))+K5;
E(i)=-2*sin(theta2(i));
F(i)=K1+(K4-1)*cos(theta2(i))+K5;
end
[A.', B.', C.', D.', E.', F.']
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Numerical Integration and Differentiation finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!