Need blue dots plotted on my figure, for some reason there not on there. Help?
조회 수: 5 (최근 30일)
이전 댓글 표시
clear
clc
%mass1 in kg
m1=1;
%mass 2 in kg
m2=0.5;
%mass 3 in kg
m3=0.2;
%pivot point in cm
rp=87;
r1=.03
%length of beam
l=2.27;
%distance of mass 2
r2=[58.7 27.8 20 59 30 31.2 68.5 67 34 60 39 50.3 50 45.3 45]';
%distance of mass 3
r3=[12.89 20.65 226 120 217 193.1 91.6 110 197.5 166 158.3 142.1 150 176.5 122]';
%changing distance between m1 and pivot
R1=rp-r1;
%changing distance between m2 and pivot
R2=rp-r2;
%changing distance between m3 and pivot
R3=r3-rp;
%changing distance between half length of the beam and the pivot
Rb=(((1/2)*.1)-rp);
%calculate independent
x=R2
%calculate dependent
y=R3
G=x;
G(:,2) = ones(length(x), 1);
delta = G \ y
slope=delta(1,1)
intercept=delta(2,1)
%mass of the beam in kg
m_b = m2./Rb.*slope-(m1./Rb).*R1
sigma = sqrt(sum((y-x).^2)./(length(x)-1));
se1 = sigma.*sqrt(1./((length(x)+mean(y)^2/((length(x)-1)*std(x)^2))));
se2 = sigma.*sqrt(1./((length (x)-1)*std(x)^2));
Ci1=tinv(.975,length(x)-1).*se1;
Ci2=tinv(.975,length(x)-1).*se2;
% creating a line of best fit
X = [min(x);1e-3;max(x)]';
Y = delta(1,1) + delta(2,1).*X;
SE=sigma.*sqrt(1/length(x)+(X-mean(x)).^2./((length(x)-1)*std(x).^2));
Ci=tinv(.975,length(x)-1).*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')
![matlab lab 5.png](https://www.mathworks.com/matlabcentral/answers/uploaded_files/198685/matlab%20lab%205.png)
댓글 수: 0
답변 (1개)
Walter Roberson
2018년 12월 10일
You have
plot(m1, m2, 'ob')
Your m1 and m2 are scalars, so you are plotting exactly one blue dot. Which does show up -- it is near the upper left edge of the red line,
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!