Why does winopen not work well?

After ranning hundreds of lines of code and export for a mat table, code winopen the folder does not worked so well while busy is displayed at the botttom left corner? Even train sould has been player, the desired path is still not opened. If you only ran the cold winopen, it works well. I do not know why?
Does anybody know how to sovlve this? Appreciate for any help or any clue.
Belllow is the end of the code I have ran.
% omit of some code for processing
outputName = fullfile(path, ,'ResSal_Type.xlsx']);
writecell(Res, outputName, 'Sheet', 'Sheet1');
disp(sprintf('Finished'));
winopen(path)
load train % loads two variables, y and Fs
sound(y, Fs); % plays the sound

2 Commenti

Code will continue after you close your application.
Haiquan
Haiquan il 16 Mar 2024
Thanks. In this condition do you know how to make sure the file will be opened by using winop(path)?

Accedi per commentare.

 Risposta accettata

dpb
dpb il 17 Mar 2024
Modificato: dpb il 17 Mar 2024
...
outputName = fullfile(path, ,'ResSal_Type.xlsx']);
writecell(Res, outputName, 'Sheet', 'Sheet1');
...
winopen(path)
...
You wrote to file outputName but then try to only open the folder -- that will open file explorer to the given folder but clearly should NOT open the file, that isn't what winopen() was asked to do.
Use
...
winopen(outputName )
...
instead.

7 Commenti

dpb
dpb il 17 Mar 2024
I'll note that if you try this for large (for system and phase of the moon dependent definitions of "large") numbers of files in a tight loop you're likely to hang and/or crash MATLAB, Excel, the system or any or all combinations of the above...
...
outputName = fullfile(path, ,'ResSal_Type.xlsx']);
Also NOTA BENE: there's a null element in the fullfile argument list -- that probably is not the intent.
dpb
dpb il 17 Mar 2024
Spostato: dpb il 18 Mar 2024
See the Answer for this follow on.
As for the code as written not opening the folder, probably the dispatch of the sound player is hanging up a system call.
Try a short time delay for the event before moving on to play the sound or perhaps a couple drawnow calls might help...
It's amost close. Really sorry. It was my fault not to state it clearly. After output the file, I want to open the folder where it was output.
disp(sprintf('Finished'));
workes well.
The last code of
load train % loads two variables, y and Fs
sound(y, Fs); % plays the sound
also works well.
But
winopen(path)
folder does not open. If after several seconds I select this line of code and press F9, it works well.
So I don't know the reason.
% some code.
disp(sprintf('Finished'));
winopen(path)
load train % loads two variables, y and Fs
sound(y, Fs); % plays the sound
dpb
dpb il 18 Mar 2024
Modificato: dpb il 19 Mar 2024
Repeating previous comment in sequence so more likely to be found...
I wrote the following earlier in response to your other comment to other respondent--
"As for the code as written not opening the folder, probably the dispatch of the sound player is hanging up a system call.
Try a short time delay for the event before moving on to play the sound or perhaps a couple drawnow calls might help..."
dpb
dpb il 19 Mar 2024
To prove the above hypothesis, try commenting out the call to sound(y,FS) temporarily.
If the winopen() call then works as expected, it is the system sound call that is blocking the other OS system call. Unfortunately, it doesn't appear that sound is supported in the threaded functionality; one can hope that maybe a drawnow would let the system have a chance to dispatch the other code...
However, a trivial case here to try to illustrate seems to work...
winopen(cd)
load gong.mat;
sound(y);
A script containing only the above here works seemingly every time (warning--the gong is quite annoying if your speaker volume is set at any great magnitude...)
See if such a trivial case will work for you...if so, and your other code still doesn't, then it begins to look like something else not shown may be the culprit instead.

Accedi per commentare.

Più risposte (0)

Categorie

Prodotti

Release

R2023b

Tag

Richiesto:

il 16 Mar 2024

Commentato:

dpb
il 19 Mar 2024

Community Treasure Hunt

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

Start Hunting!

Translated by