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;

조회 수: 11 (최근 30일)
for i=1:10
global m(i,1) = a;
function p = h()
global m(i,1);
m(i,1)
endfunction
h()
  댓글 수: 5
Lakshmikruthiga Ponnusamy
Lakshmikruthiga Ponnusamy 2019년 1월 7일
@SHUBHAM GUPTA , I've updated using code button now. I also tried help global, there wasn't any mention of declaring arrays as a variable. I mean m(i,1)
Walter Roberson
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
madhan ravi 2019년 1월 7일

카테고리

Help CenterFile Exchange에서 Octave에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by