MATLAB Answers

0

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

Asked by Francisco Michel on 13 Oct 2018 at 23:54
Latest activity Commented on by Francisco Michel on 14 Oct 2018 at 0:31
Accepted Answer by dpb
fid= fopen('cities.txt','r');
State=input('Which state would you like to vist in the United States', 's');
filedata=textscan(fid,'%s%s%s%s%s','Delimiter','\t','headerlines',1);
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);
radian=deg2rad(angle);
radian1=deg2rad(angle1);
d=dist(radian,radian1,R);
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

rad =  deg*pi()/180
and my distance function 
function[d]=dist(radian,radian1,R)
  d=2*R * arcsin* sqrt(sin(degree2-degree1)/2)^2+ cos(degree1)*cos(degree2)*( sin(degree4-degree3)/2)^2;

  0 Comments

Sign in to comment.

1 Answer

Answer by dpb
on 14 Oct 2018 at 0:19
 Accepted Answer

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...

  1 Comment

thank you for your help i really appreciate it

Sign in to comment.