What is the error in this script file?

points=input('Input number of points:');
coord=zeros(points,2);
coord(1,:)=input('Input initial coordinate');
for n=1:points
length(n)=input('Enter Distance of Leg:');
angle(n,:)=DMS_to_RAD(input('Enter Bearing in [Degrees Minutes Seconds]:'));
bearing(n)=input('Enter 1,2,3, or 4 for NW NE SE SW Bearing');
if bearing(n)==1
NA_RAD(n)=2*(pi)-Rad(n);
elseif bearing(n)==2
NA_RAD(n)=Rad(n);
elseif bearing(n)==3
NA_RAD(n)=3*(pi)/2-Rad(n);
elseif bearing(n)==4
NA_RAD(n)=pi/2-Rad(n);
else
end
coord(n+1,:)=Next_coord(coord(n,:)),length(n),NA_RAD(n);
end

3 件のコメント

Azzi Abdelmalek
Azzi Abdelmalek 2013 年 2 月 11 日
What are your error messages?
Walter Roberson
Walter Roberson 2013 年 2 月 11 日
When you 'Input initial coordinate' are you entering two values at the prompt?
ChristianW
ChristianW 2013 年 2 月 11 日
Last line lookin strange, Next_coord not defined and wierd braces.
coord(n+1,:) = Next_coord(coord(n,:)) , length(n), NA_RAD(n) ;

サインインしてコメントする。

回答 (1 件)

Jan
Jan 2013 年 2 月 11 日
編集済み: Jan 2013 年 2 月 11 日

0 投票

Azzi's comment points to the most efficient approach to solve your problem: What is the error message?
Matlab's error messages contain very useful information, so reading them is a good strategy, and if they do not help you directly, please post them at least in the forum. You script can contain millions of different bugs. E.g. if you have re-defined any of the used Matlab functions as local variable, almost any line could crash. An example is using "length" as a variable: Afterwards Matlab's length() function is not called anymore. This leads to strange reactions frequently.
Anyhow, the last line does not close the parenthesis properly, as Christian W has mentioned already:
coord(n+1,:) = Next_coord(coord(n,:)), length(n), NA_RAD(n) % ERROR
coord(n+1,:) = Next_coord(coord(n,:), length(n), NA_RAD(n)) % Cleaner

カテゴリ

ヘルプ センター および File ExchangeLoops and Conditional Statements についてさらに検索

質問済み:

2013 年 2 月 11 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by