clearclc m1=1; m2=0.5; m3=0.2; rp=87; R1=rp-r1; R2=rp-r2; R3=r3-rp; l=2.27; r2=[58.7 27.8 20 59 30 31.2 68.5 67 34 60 39 50.3 50 45.3 45]'; r3=[12.89 20.65 226 120 217 193.1 91.6 110 197.5 166 158.3 142.1 150 176.5 122]'; Rb=(((1/2).1)-rp); x=R2 y=R3 G=x;G(:,2) = ones(length(x), 1);delta = G \ yslope=delta(1,1)intercept=delta(2,1)m_b = m2./Rb.*slope-(m1./Rb).*R1sigma = 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)clfplot(m1, m2, 'ob')hold on% plotting the conidence intervals
plot (X, Y, 'R')plot(X,Y+Ci,'g--')plot(X,Y-Ci,'g--')hold offxlabel('$$-$$','interpreter','latex')ylabel('$$-)$$','interpreter','latex')print(figure(1), '-dpng', 'figure1')
MATLAB: Error in code, “Invalid expression. Check for missing multiplication operator, missing or unbalanced delimiters, or other syntax error. To construct matrices, use brackets instead of parentheses. “
dataequationerrorinvalid expression
Best Answer