Statup script executes as a function

Hi there,
I defined a startup.m script to excute when I start MatLab. I followed all of the instructions in Specify Startup Options.
When I start MatLAb, I get the following error lines
Attempt to execute SCRIPT startup as a function:
C:\Users\antho\Documents\MATLAB\StartupDir\startup.m
Hopefully the startup script does work properly! But it is very anoying to have that "error sound" and message that appears everytime I run MatLab ...
Here is my startup.m file
set(groot, ...
'defaultAxesFontSize',14, ...
'defaultAxesLabelFontSize',1.35, ...
'defaultTextFontSize',14, ...
'defaultTextFontSizeMode','manual',...
'defaultLegendFontSize',18, ...
'defaultLegendFontSizeMode','manual',...
...
'defaultTextInterpreter','latex',...
'defaultAxesTickLabelInterpreter','latex',...
'defaultLegendInterpreter','latex',...
...
'defaultLineLineWidth',2, ...
...
'defaultAxesXGrid','on', ...
'defaultAxesYGrid','on', ...
'defaultLegendBox','on', ...
'defaultLegendLocation', 'northeast',...
'defaultAxesBox', 'on' ...
)
%% Check
disp('statup.m all done!');
It isn't a function, and it should not be one!
Do anyone knows how to fix this ?
Thanks!
Anthony.

댓글 수: 6

Prudhvi Peddagoni
Prudhvi Peddagoni 2021년 1월 19일
Hi,
I have tried reproducing this on MATLAB 2020a on windows. I did not get any error.
I have created a file named startup.m in the path given by userpath command. And added this script to it. I did not get any error message or sound. Can you tell me which MATLAB version you are using?
Anthony Amorosi
Anthony Amorosi 2021년 1월 21일
Hello Prudhvi, thanks for your help.
My version of MatLab is 2020b. It used to work fine on my previous computer.
I check my userpath folder. The script is in a folder within the userpath folder. But I guess this is not where the issue comes from.
Anthony.
@Anthony Amorosi: please show the complete output of this command:
which startup -all
Anthony Amorosi
Anthony Amorosi 2021년 1월 21일
편집: Anthony Amorosi 2021년 1월 21일
Hi, here it is
C:\Users\antho\Documents\MATLAB\StartupDir\startup.m
Stephen23
Stephen23 2021년 1월 21일
편집: Stephen23 2021년 1월 21일
Interesting. Try the following:
Do you have any third-party toolboxes installed?
Anthony Amorosi
Anthony Amorosi 2021년 1월 21일
Hi Stephen,
I tried your suggestions but it was not helping.
But when I renamed the startup file, I remember I should also be changing the text in the Target field of my MatLab shortcut icon, as it was specified in Specify Startup Options.
"C:\Program Files\MATLAB\R2020b\bin\matlab.exe" -r "startup"
At first it did not solve the issue. But then I had the idea of simply removing -r "startup" and I got my problem fixed!!
Maybe this MatLab documentatin in Specify Startup Options is not up-to-date, or I maybe I got it wrong, but in any case the target field should have been left as it is by default.
Thanks anyway @Stephen Cobeldick and @Prudhvi Peddagoni for helping me with this anoying issue.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

도움말 센터File Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

제품

릴리스

R2020b

태그

질문:

2021년 1월 13일

댓글:

2021년 1월 21일

Community Treasure Hunt

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

Start Hunting!

Translated by