フィルターのクリア

What is wrong with following code?

2 ビュー (過去 30 日間)
Altin Guberi
Altin Guberi 2017 年 6 月 2 日
編集済み: James Tursa 2017 年 6 月 2 日
function Z =ush25(x)
x(1)=x;
x(2)=y;
z=3*sin(0.5+0.25.*x(1).*x(2).*cos(x(1)))
end
I get Error in ush25 (line 3) x(1)=x;
What can I do?
  1 件のコメント
Stephen23
Stephen23 2017 年 6 月 2 日
@Altin Guberi: please edit your question and show the complete error message. This means all of the red text.

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

回答 (1 件)

Guillaume
Guillaume 2017 年 6 月 2 日
x(1) = x;
There are two possibilities:
  • x is scalar, i.e. it has only one element. In which case, the above is simply assigning x to itself. The line is completely pointless
  • x is not scalar. In which case it tries to assign the whole of x to the first element of x. This is not going to work. You can't put multiple elements into one element. This is probably why you get an error.
Either way, the line makes no sense. Without knowning what it is you're trying to do, that's all we can say.
  2 件のコメント
Rik
Rik 2017 年 6 月 2 日
We can say one more thing: the next line you are trying to assign y to the second element of x. y does not exist at that point, so that line will result in an error as well.
Walter Roberson
Walter Roberson 2017 年 6 月 2 日
y could theoretically be a function name, so the line is not definitely wrong.... just very very likely so.

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

カテゴリ

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

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by