Undefined function or variable 'p1x'.

1 回表示 (過去 30 日間)
Daniel Wurster
Daniel Wurster 2019 年 6 月 16 日
コメント済み: Daniel Wurster 2019 年 6 月 16 日
I know, another "undefined function or variable ...." question, but i read through the other answers and still dont know whats wrong here.
I took a self written c programm and tried to put it into matlab code:
function [ab, la] = linepoint (p1x, p1y, p2x, p2y, p3x, p3y)
%%
la = sqrt((p2x-p1x)^2 + (p2y-p1y)^2);
%%Intitialize
d1 = p2x - p1x;
d2 = p2y - p1y;
er = sqrt(d1*d1+d2*d2);
u = (((p3x - p1x) * (p2x - p1x)) + ((p3y - p1y) * (p2y - p1y)))/(er*er);
if lt(u,0)
false;
else
p4x = p1x + u*(p2x-p1x);
p4y = p1y + u*(p2y-p1y);
ab = sqrt((p4x-p3x)^2 + (p4y-p3y)^2);
end
Clicking on run i get: Undefined function or variable 'p1x'.
What have i done wrong here? I c-code p1x is an integer type and no error occures.

回答 (1 件)

Walter Roberson
Walter Roberson 2019 年 6 月 16 日
Your code requires six inputs. When you click on Run, you are providing zero inputs. Where are you expecting it to get the value of p1x from when you click on Run ?
  1 件のコメント
Daniel Wurster
Daniel Wurster 2019 年 6 月 16 日
you're right. My bad :-(

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

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by