Can't solve matrix dimension issue and define a variable.

6 次查看(过去 30 天)
Hello,
Can someone help me, how can I remove matrix dimension issue. The error is ''Undefined function or variable y''.
I want to use y data which is a vector (line-146) and is obtained/calculated in line-134.
y is not declared and I want to create it in the main code while calling and receiving the function.
I would be thank ful if anyone can edit the attached code.
Thanks
  2 个评论
Rik
Rik 2021-6-9
The original question from the Google cache (without the attachment):
Can't solve matrix dimension issue and define a variable.
Hello,
Can someone help me, how can I remove matrix dimension issue. The error is ''Undefined function or variable y''.
I want to use y data which is a vector (line-146) and is obtained/calculated in line-134.
y is not declared and I want to create it in the main code while calling and receiving the function.
I would be thank ful if anyone can edit the attached code.
Thanks

请先登录,再进行评论。

回答(2 个)

Sulaymon Eshkabilov
Hi,
You need to pre-define y before x being computed. Otherwise, y can't be computed within your nested function.
  2 个评论
Walter Roberson
Walter Roberson 2021-5-25
The function basic is not a nested function, so it does not use shared variables.
The user needs to redefine function basic so as to pass in y.
Zain
Zain 2021-5-26
Can you please do it, I tried but couldn't manage to implement it.
I'm a bit new to this.

请先登录,再进行评论。


Walter Roberson
Walter Roberson 2021-5-26
Repaired function attached.
I also improved the main function so that x and y are returned if you assign the output of the function to something. For example
[x, y] = aaaaaa;

类别

Help CenterFile Exchange 中查找有关 Programming 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by