## I call a function but i keep receiving that the input i place are not assigned

### Francisco Michel (view profile)

on 13 Oct 2018
Latest activity Commented on by Francisco Michel

on 14 Oct 2018

### dpb (view profile)

fid= fopen('cities.txt','r');
State=input('Which state would you like to vist in the United States', 's');
data=find(strcmp(filedata{4},State));
lat=filedata{1}(data);
long=filedata{2}(data);
Long=cell2mat(long);
Lat=cell2mat(lat);
Degree2=Lat(1:1);
Degree1=Lat(1:2);
Degree3=Long(1:1);
Degree4=Long(1:2);
R=6360;
angle= C_dec(Degree1,Degree2);
angle1= C_dec(Degree3,Degree4);
fprintf(d)
I receive the error the error
Output argument "deg" (and maybe others) not assigned during call to "C_dec"
here is my function for C_dec
function[deg] =C_dec(O1,O2)
c_dec =01 + (02/60);
as well as the degree to radian function
and my distance function
d=2*R * arcsin* sqrt(sin(degree2-degree1)/2)^2+ cos(degree1)*cos(degree2)*( sin(degree4-degree3)/2)^2;

### dpb (view profile)

on 14 Oct 2018

function[deg] =C_dec(O1,O2)
c_dec =01 + (02/60);
The return value in the function definition is "deg"; you calculate "c_dec" instead.
Either
function[c_dec] =C_dec(O1,O2)
or
deg =01 + (02/60);
your choice will fix the problem. (I'd probably choose the latter, but it's your call).
I think "O1, O2" are remarkably uninformative choices for dummy argument variable names, however; I'd strongly recommend something that has some indication of what they are. The 'puter doesn't care; but would make maintenance in future easier as well as give somebody else at least a chance to know what is what. There are no comments in sight, either...

Francisco Michel

### Francisco Michel (view profile)

on 14 Oct 2018
thank you for your help i really appreciate it