Question: So I keep getting this error when I try to run my script Subscript indices must either be real positive integers or logicals. And with

So I keep getting this error when I try to run my script "Subscript indices must either be real positive integers or logicals." And with further inspection it seems that, that is because my function file is operating properly but I'm getting negative integers in my array.. which using the sample numbers is exactly what is supposed to happen. What am I missing from my function/script to stop this?

_____________Script___________________________________________________________________

L=input('Enter a positive value for the length of the beam in inches: ');

P=input('Enter a positive value for the mass of the load in pounds: ');

E=input('Enter a positive value for modulus of elastifity in psi: ');

I=input('Enter a positive value for moment of inertia: ');

A=input('Enter a value (greater than or equal to 2) for the number of equidistant points for the deflection to be calculated along the beam: ');

max_Def(1i)=(-P*b.*((L^2)-(b.^2))^(3/2))/(9*(sqrt(3))*E*I*L);

b=L-A;

def_at_Load(1i)=((-P*A^2)*(b.^2))/(3*E*I*L);

def_at_Center(1i)=(-P*b.((3*L^2)-(4*b.^2)))/(48*E*I);

deflection [max_Def,def_at_Load,def_at_Center]

_______________________________________________Function_________________________________

function [ max_Def,def_at_Load,def_at_Center ] = deflection( A,P,I,L,E )

%DEFLECTION to calculate the Max def. a def at load, and def in the center

%of a beam

b=L-A;

for j=1:length(A)

max_Def(j)=(-P*b.*((L^2)-(b.^2))^(3/2))/(9*(sqrt(3))*E*I*L);

def_at_Load(j)=((-P*A^2)*(b.^2))/(3*E*I*L);

def_at_Center(j)=(-P*b.((3*L^2)-(4*b.^2)))/(48*E*I);

end

x=0;

while x<=0

x=input('Enter x as a positive number: ');

if x<=0

fprintf(' You entered a non-positive number. ');

end;

end;

end

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!