How to access global variable inside function. Note that I am using octave. the value of variable 'a' changes continuously. I'm getting syntax error >>> global m(1,1) = a;
显示 更早的评论
for i=1:10
global m(i,1) = a;
function p = h()
global m(i,1);
m(i,1)
endfunction
h()
5 个评论
Shubham Gupta
2019-1-7
Please edit your question by clicking on code button from above toolbar to increase readability of the code. Also did you try ' help global ' for synatx ?
KSSV
2019-1-7
If the value change why you want to make it global? Using global variable is a bad idea...you better make the variable a input to the function.
Lakshmikruthiga Ponnusamy
2019-1-7
Lakshmikruthiga Ponnusamy
2019-1-7
Walter Roberson
2019-1-7
You appear to be using octave specific features that have no MATLAB counterpart . MATLAB would never permit a function to be defined inside a loop, so we have no analogy in MATLAB to go on. You need to go ask octave questions in an octave forum .
I would have closed this question as being irrelevant to a MATLAB forum but madhan has made aa significant contribution so I will leave it open.
回答(1 个)
madhan ravi
2019-1-7
0 个投票
类别
在 帮助中心 和 File Exchange 中查找有关 Octave 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!