MATLAB: How to run an entire M-file without adding it to the path, in MATLAB 8.0 (R2012b)
MATLAB
I want to directly run an M-file with several sections that I have opened in the Editor.
I would like the functionality of the "Evaluate entire file" option which was available in previous releases.
Best Answer
The "Evaluate entire file" option is not available in the Toolstrip.
A workaround would be to create a shortcut with the following code :
activeEditor = matlab.desktop.editor.getActive;
eval(activeEditor.Text);
This code creates an object of class matlab.desktop.editor which has the property 'Text' that contains all the text included in the active file of the Editor. By using 'eval(activeEditor,Text)' you are evaluating all the commands included in the file.
Your function is calling itself without approaching any convergance or something that will allow it to end. Therefore it will run forever and eventually out of memory (hence the error). Try splitting it up into a script and a function as so:
Script:
%creating window of plot from -5 to 50 using stepsize 0.25 for t x-axis
%t should be on the x axis, v should be on the y axis
k=0;
for i= -5:.25:50
k = k+1;
t(k)=i;
v(k)=vPieceWise(t(k));
end
plot(t,v);
figure
plot(t,v);
hold on
Function:
%Part A: Mfile function to compute v as a function of t
Best Answer