MATLAB Answers

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

5 views (last 30 days)
Zain
Zain on 25 May 2021
Commented: Rena Berman on 29 Jun 2021 at 14: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 Comments

Sign in to comment.

Answers (2)

Sulaymon Eshkabilov
Sulaymon Eshkabilov on 25 May 2021
Hi,
You need to pre-define y before x being computed. Otherwise, y can't be computed within your nested function.
  2 Comments
Zain
Zain on 26 May 2021
Can you please do it, I tried but couldn't manage to implement it.
I'm a bit new to this.

Sign in to comment.


Walter Roberson
Walter Roberson on 26 May 2021
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;

Community Treasure Hunt

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

Start Hunting!

Translated by