MATLAB: How do i resolve the error Index exceeds matrix dimensions

errorMATLAB

prompt=('Enter your reponse:1=geodetic to cartesian 2=cartesian to geodetic');
x1=input(prompt);
if x1==1
prompt('enter the lattitude');
phi=input(prompt);
prompt('enter the longitude');
lambda=input(prompt);
prompt('enter the height');
h=input(prompt);
%using WGS84 parameters
a=6378137;
b=6356752.314245;
e=(1-((b/a)^2))^0.5;
N=a/((1-((e^2)*((sin(phi))^2)))^0.5);
x=(N+h)*cos(phi)*cos(lambda);
y=(N+h)*cos(phi)*sin(lambda);
z=((N*(1-(e^2)))+h)*sin(phi);

Best Answer

rohan - I suspect the error is from the line
prompt('enter the lattitude');
and every similar line. If you are trying to assign a string to the prompt variable, then just do
prompt = 'enter the latitude';
otherwise, you are treating the prompt variable as an array which you are trying to access with a string of character...