Is there a way to run a MATLAB script from a specific line without a GUI?

Is there a way to run a MATLAB script from a specific line without using a GUI.

In the GUI, I use %%.

thank

+3
source share
3 answers
+3
source

, script m, , , m, . 1 2. , Matlab , . , , - .

UPDATE

:

function runfromto(mfile, lfrom, lto)
% Runs mfile script from line lfrom to line lto.
if nargin < 1
    error('No script m-file specified.');
end
if ~strcmp(mfile(end-1:end),'.m')
    mfile = [mfile '.m'];
end
if ~exist(mfile,'file')
    error(['Cannot access ' mfile])
end
M = textread(mfile,'%s','delimiter','\n');
if nargin < 2
    lfrom = 1;
end
if nargin < 3 || lto > numel(M)
    lto = numel(M);
end
if lfrom > numel(M)
    error(['Script contains only ' num2str(numel(M)) ' lines.'])
end

for k=lfrom:lto
    try
        evalin('base',M{k})
    catch ME
        error('RunFromTo:ScriptError',...
            [ME.message '\n\nError in ==> ' mfile ' at ' num2str(k) '\n\t' M{k}]);
    end
end

2 .

+4

- goto Husam Aldahiyat:

https://de.mathworks.com/matlabcentral/fileexchange/26949-matlab-goto-statement

goto("your line") 
return

matlab script.

0

Source: https://habr.com/ru/post/1734707/


All Articles