I'm using the online program version, I fixed what you said but got another error. "Unexpected MATLAB ERROR" "MATLAB has encountered an internal problem and needs to be closed" Also my values for k arent printing out and how can I fix the figures 1
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Error
I'm using the online program version, I tried fixing my erros from my previous question but got another error.
"Unexpected MATLAB ERROR"
"MATLAB has encountered an internal problem and needs to be closed"
Also my values for k arent printing out and how can I fix the figures 1 and 2 from having all the points looking jumbled together like that?
Code
%These commands clear the workspace and command window, in that order.
clear
clc
% Measured masses of spring 1, 2 and 3 measured in meters(m).
M1=[1e-6 .1 .2 .3 .4 .5 .6 .7 .8 .9]';
M2=[1e-6 .05 .1 .15 .2 .25 .3 .35 .4 .45]';
M3=[.05 .07 .09 .11 .13 .15 .17 .19 .21 .23]';
% Measured distances of spring 1, 2, and 3 measured in kilograms(kg).
L1=[.075 .085 .095 .105 .115 .125 .135 .145 .155 .165]';
L2=[.11 .145 .185 .225 .265 .305 .345 .375 .415 .455]';
L3=[.365 .455 .515 .585 .655 .735 .785 .885 .945 .995]';
g=(9.81);
L01=.19
L02=.08
L03=.1
x1 = ((1) ./ (M1 .* g));
y1 =((1) ./ (L1-L01));
x2 = ((1) ./ (M2 .*g));
y2 =((1) ./ (L2-L02));
x3 = ((1) ./ (M3 .* g));
y3 =((1) ./ (L3-L03));
G1= ones(length(x1), 1);
% G(:, 1) = b;
G1(:, 2) = x1;
k1 = G1 \ y1
G2 = ones(length(x2), 1);
G2(:, 2) = x2;
k2 = G2 \ y2
G3= ones(length(x3), 1);
% G(:, 1) = b;
G3(:, 2) = x3;
k3 = G3 \ y3
% uncertainties
sigma1 = sqrt(sum((y1-G1*k1).^2)./(length(x1)-2));
sigma2 = sqrt(sum((y2-G2*k2).^2)./(length(x2)-2));
sigma3 = sqrt(sum((y3-G3*k3).^2)./(length(x3)-2));
se11 = sigma1.*sqrt(1./((length(x1)+mean(x1)^2/((length(x1)-1)*std(x1)^2))));
se12 = sigma2.*sqrt(1./((length(x2)+mean(x2)^2/((length(x2)-1)*std(x2)^2))));
se13 = sigma3.*sqrt(1./((length(x3)+mean(x3)^2/((length(x3)-1)*std(x3)^2))));
se21 = sigma1.*sqrt(1./((length (x1)-1)*std(x1)^2));
se22 = sigma2.*sqrt(1./((length (x2)-1)*std(x2)^2));
se23 = sigma3.*sqrt(1./((length (x3)-1)*std(x3)^2));
% creating a line of best fit
X1 = [min(x1):1e-3:max(x1)]';
Y1 = k1(1,1) + k1(2,1).*X1;
X2 = [min(x2):1e-3:max(x2)]';
Y2 = k2(1,1) + k2(2,1).*X2;
X3 = [min(x3):1e-3:max(x3)]';
Y3 = k3(1,1) + k3(2,1).*X3;
SE1=sigma1.*sqrt(1/length(x1)+(X1-mean(x1)).^2./((length(x1)-1)*std(x1).^2));
Ci1=tinv(.975,length(x1)-2).*SE1;
SE2=sigma2.*sqrt(1/length(x2)+(X2-mean(x2)).^2./((length(x2)-1)*std(x2).^2));
Ci2=tinv(.975,length(x2)-2).*SE2;
SE3=sigma3.*sqrt(1/length(x3)+(X3-mean(x3)).^2./((length(x3)-1)*std(x3).^2));
Ci3=tinv(.975,length(x3)-2).*SE3;
figure(1)
clf
plot(x1, y1, 'ob')
hold on
% plotting the conidence intervals
plot (X1, Y1, 'g')
plot(X1,Y1+Ci1,'g--')
plot(X1,Y1-Ci1,'g--')
hold off
xlabel('$$\frac{1}{mg}$$','interpreter','latex')
ylabel('$$\frac{1}{l_1-l_0}$$', 'interpreter','latex')
title('Spring Constant')
print(figure(1), '-dpng', 'figure1')
figure(2)
clf
plot(x2, y2, 'ob')
hold on
% plotting the conidence intervals
plot (X2, Y2, 'R')
plot(X2,Y2+Ci2,'g--')
plot(X2,Y2-Ci2,'g--')
hold off
xlabel('$$\frac{1}{mg}$$','interpreter','latex')
ylabel('$$\frac{1}{l_1-l_0}$$','interpreter','latex')
title('Spring Constant')
print(figure(2), '-dpng', 'figure2')
figure(3)
clf
plot(x3, y3, 'ob')
hold on
% plotting the conidence intervals
plot (X3, Y3, 'y')
plot(X3,Y3+Ci3,'g--')
plot(X3,Y3-Ci3,'g--')
hold off
xlabel('$$\frac{1}{mg}$$','interpreter','latex')
ylabel('$$\frac{1}{l_1-l_0}$$','interpreter','latex')
title('Spring Constant')
print(figure(3), '-dpng', 'figure3')
0 comentarios
Respuestas (1)
Image Analyst
el 27 de Nov. de 2018
Editada: Image Analyst
el 27 de Nov. de 2018
4 comentarios
Image Analyst
el 27 de Nov. de 2018
Perhaps. Try it and see. Often hard crashes like that are very hardware dependent. Try the same program on different computers.
Ver también
Categorías
Más información sobre Get Started with MATLAB en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!