Receiving errors. Undefined variables etc

3 visualizzazioni (ultimi 30 giorni)
Bria Johnson
Bria Johnson il 9 Dic 2018
Riaperto: Star Strider il 10 Dic 2018
Hello,
I am creating a code to find the mass of a beam after balancing it. I had 3 weights. Only 2 of 3 weights could be moved to balance the beam. I am having trouble with my code. I will attach my code and the errors below.
clear
clc
m1 = 1;
% mass 1, measured in kilograms.
m2 = 0.5;
% mass 2, measured in kilograms.
m3 = 0.2;
% mass 2, measured in kilograms.
rp = 0.87;
% distance of pivot, measured in meters.
r1 = 0.03;
% constant distance of mass 1, measured in meters.
r2 = [0.587 0.278 0.2 0.59 0.312 0.685 0.67 0.34 0.503 0.50 0.453]';
% distances obtained when moving mass 2.
r3 = [0.1289 0.2065 2.26 1.2 1.931 0.916 1.1 1.975 1.583 1.421 1.5 1.765]';
% distances obtained when moving mass 3.
l = 2.27;
% length of the beam measured in meters.
g = 9.8;
% gravitational constant measured in meters per seconds squared.
G = ones(length(m1), 2);
G(:,2) = m1;
m = G \ m2
rb = (0.5.*l-rp);
b = (m_b/m2).*rb-(m1/m2).*rb;
m_b =(m2/rp).*b *((-m1)/(rp));
sigma = sqrt(sum((m2-G*m).^2)./(length(m1)-2));
se1 = sigma.*sqrt(1./((length(m1)+mean(m1)^2/((length(m1)-1)*std(m1)^2))));
se2 = sigma.*sqrt(1./((length (m1)-1)*std(m1)^2));
Ci1=tinv(.975,length(m1)-2).*se1;
Ci2=tinv(.975,length(m1)-2).*se2;
% creating a line of best fit
X = [min(m1);1e-3;max(m1)]';
Y = m(1,1) + m(2,1).*X;
SE=sigma.*sqrt(1/length(m1)+(X-mean(m1)).^2./((length(m1)-1)*std(m1).^2));
Ci=tinv(.975,length(m1)-2).*SE;
figure(1)
clf
plot(m1, m2, 'ob')
hold on
% plotting the conidence intervals
plot (X, Y, 'R')
plot(X,Y+Ci,'g--')
plot(X,Y-Ci,'g--')
hold off
xlabel('$$-$$','interpreter','latex')
ylabel('$$-)$$','interpreter','latex')
print(figure(1), '-dpng', 'figure1')
  2 Commenti
Star Strider
Star Strider il 9 Dic 2018
You and your classmate seem to be having similar problems!
It would help significantly if you describe the problem you are having, preferably in some detail.
Bria Johnson
Bria Johnson il 9 Dic 2018
The goal is to find the mass of the beam. I am having trouble with all of the variables/componets of the equation for mb. In my code I incorporated the equation for b, which is the y intercept however i am still receiving errors.

Accedi per commentare.

Risposte (0)

Categorie

Scopri di più su 2-D and 3-D Plots in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by