Why is the run option greyed out here? What am I doing wrong with this function?

258 ビュー (過去 30 日間)
Kevin Burke
Kevin Burke 2022 年 9 月 13 日
コメント済み: Les Beckham 2022 年 9 月 13 日
  3 件のコメント
Kevin Burke
Kevin Burke 2022 年 9 月 13 日
How can i fix this? I am doing an assignment that asked for a nested function with two outputs and three inputs inside of a parent function with just three inputs. Maybe I interpreted this incorrectly.
Bruno Luong
Bruno Luong 2022 年 9 月 13 日
You need somehow to call the main function, and the main function needs somehow calling the nested function. Otherwise they just sitting there doing nothing.

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

回答 (1 件)

Cris LaPierre
Cris LaPierre 2022 年 9 月 13 日
It is grayed out because you must call a function with inputs in a live script. See the note at the bottom of this page:
"Running live functions in the Live Editor using the Run button is only supported in MATLAB Online™. When you run a live function using the Run button, the output displays in the Command Window. To run a live function in an installed version of MATLAB, call the function from the Command Window or from a script or live script."
To test your functions in the live editor using the run button, add the following line before your functions. You will then be able to use the Run button.
physics(10,0,52)
Your nested function is never called by the parent function, so will never run.
Also, the point of a function is to call it with various inputs. Therefore, it should be unnecessary to define velocity, height, and angle inside your function when those are your input variables. Your code is replacing the input values with the hard coded values.
  5 件のコメント
Cris LaPierre
Cris LaPierre 2022 年 9 月 13 日
Try restarting MATLAB
Les Beckham
Les Beckham 2022 年 9 月 13 日
You are still never actually calling the dist_vel function.
Try adding this line of code immediately after the function physics(v,h,a) line
[velocity, time] = dist_vel(v,h,a)

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

カテゴリ

Help Center および File ExchangeIntroduction to Installation and Licensing についてさらに検索

製品


リリース

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by