A problem about the lost of ' when I start matlab function using command with string as input argument.
Ältere Kommentare anzeigen
I have a function called CMDEntryExitSuperColoc, with a file path string as input.
In the 1st attempt, I could run this function immediately as a new instance of Matlab by input following into command window:
%%%%%%%%%%
system('matlab -r CMDEntryExitSuperColoc(''D:\QMDownload\SuperColocParaImport1.txt'')')
%%%%%%%%%%
In a 2nd attempt, I need automatically restart computer and run this function by SchTasks. I do it as follows:
%%%%%%%%%%
taskname = 'SuperColocRescue';
runfile = ['C:\Program Files\MATLAB\R2016a\bin\matlab.exe -nosplash -nodesktop -minimize -r CMDEntryExitSuperColoc(''D:\QMDownload\SuperColocParaImport1.txt'')'];
frequency = 'ONCE';
starttime = '21:45';
system(['schtasks /create /tn "',taskname,'" /tr "',runfile,'" /sc ',frequency,' /st ',starttime,' /f']);
!shutdown /f /r /t 1
%%%%%%%%%%
This is what I got:
%%%%%%%%%%
To get started, type one of these: helpwin, helpdesk, or demo.
For product information, visit www.mathworks.com.
CMDEntryExitSuperColoc(D:\QMDownload\SuperColocParaImport1.txt)
|
Error: Unexpected MATLAB operator.
%%%%%%%%%%
It seems that the ' in the system('matlab... command works, and the function execute directly and siilently without the explicit command information showing on scrren, But the system(['schtasks... commands has a additional interpration procedure as indicated by the explicit CMDEntryExitSuperColoc(D:\QMDownload\SuperColocParaImport1.txt) in the command windows once initialized. However, the ' was lost, and it is no longer a string.
Dose the ' loss caused by Matlab or Windows Task scheduler?
Is there a smart way to input strings without the use of ' with system(['schtasks... command?
Just now I come up with an idea. Convert the path string to numbers, and use,this number as input to avoid ' useage. Then inside the function convert back to string. How to do it?
3 Kommentare
dpb
am 5 Mai 2017
Dunno, haven't played at that level for too long...I forget a lot of the ploys! :(
I do note that you don't have the double quotes ("} around the program filename which has embedded blank (an abomination shouldn't allow, but...) in the 'Program Files' subdir. I'd fix that first and see if that's causing any grief and other symptoms might go away (or at least change).
Will your scheduler accept input from a file? That might simplify things some as well.
raym
am 6 Mai 2017
raym
am 6 Mai 2017
Akzeptierte Antwort
Weitere Antworten (1)
Walter Roberson
am 6 Mai 2017
system('matlab -r CMDEntryExitSuperColoc(''''D:\QMDownload\SuperColocParaImport1.txt'''')')
1 Kommentar
Kategorien
Mehr zu Debugging and Analysis finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!