I have written a .m file which has definition of many matrices. Now, I want to add some of them, and do some other operations. Now I could write those operations in the file itself and run it in octave-cli to see the results, but I would like to load the definitions, and do the operations one by one in the input field of octave GUI (similar to what can be done in a mathematica notebook), but I don't want to type all the lines manually in octave gui once again. How to load the lines to octave's workspace?
For example, suppose the contents of somedefinitions.m
is
function somedefinitions()
c = 4;
d = 5;
Now I want this to load into octave gui, and want to evaluate c+d, c*d etc. in the input field (but I don't want to manually write definitions of c and d in the octave-gui).
How to do this? I tried load somedefinitions.m
but this says it cannot determine the file format.
somedefinitions
because its not data. If you call the filesomedefinitions.m
but do not make it a function, then you can callsomedefinitions
in your main code. That will execute everything insomedefinitions.m
and load it in the worspace. Then you can do whatever you want in the command window. You can not do it now because functions have their own worspace, so even if you would try it as it is not, variables would be defined insidesomedefinitions
but deleted when finished. In short, delete the first line of your example, and just call that script. – Ander Bigurierror: invalid call to script /path/to/somedefinitions.m
when I runload(somedefinitions.m)
in the gui. – Archisman Panigrahisomedefinitions
and it will execute the script, as I said in my previous comment. – Ander Biguri