MATLAB Answers

Unrecognized variable that has been stated

150 ビュー (過去 30 日間)
Tyde Hilderbrandt
Tyde Hilderbrandt 2020 年 3 月 29 日
回答済み: Hiro 2020 年 3 月 30 日
I'm trying to complete a homework which asks for the use of global and function which has inputs of the first column of input and second column of input. The outputs are the first colmn*A/c and each element of the second column to the power of B/C. Here is the problem I keep running into eventhough I have defined the variable.

  4 件のコメント

表示 1 件の古いコメント
Tyde Hilderbrandt
Tyde Hilderbrandt 2020 年 3 月 29 日
Okay, I think I got it, but im not confident in my awnser so I would like some reasurrance that im on the right path.
Rik 2020 年 3 月 29 日
Read the warnings that mlint is giving you. You are not using the input variables, you are not creating the output variables and you are not using the global variables you are defining. When you try to run this it will error for two reasons: it will call itself in an infinite recursion, and you will be trying to use the variable a, which has not been defined yet.
I have a major point of criticism here with your use of globals in the first place. They should be avoided if at all possible (and often it is possible). If you absolutely cannot avoid it you should be using very long descriptive names for the global variables and try to limit their number (e.g. by using a struct). You have a limit of 63 characters to create a name, use them. It is your teacher's job to imprint this as well.
Tyde Hilderbrandt
Tyde Hilderbrandt 2020 年 3 月 30 日
Thanks for the input, good to know sense my professor did not mention the avoidance of global, or I did not notice it. As for the code, the new one does not give an error, but that dosnt mean its output is wrong. I think he is trying to intoduce us to the global command, this is an intro class, and he is requring we use A,B,C,D and small numbers based off our ID#.


回答 (1 件)

Hiro 2020 年 3 月 30 日
I guess the intention of the Professor is about "work space and variables".
I would reccomend to learn from the following site
Hope this gives you a clear picture about the work space and so on so forth.

  0 件のコメント


Community Treasure Hunt

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

Start Hunting!

Translated by