Programmatically ejecting an external hard drive

I'm currently running long scripts using data stored on multiple external hard drives connected via USB. My computer is smartcard-only, meaning that whenever I leave a script running and come back a while later, I have to "yank out" one of the cables in order to get back in. Often however the script actually finished hours before!
I'm wondering if there's a way to include an "eject hard drive" command at the end of the script. I did some searching of keywords and can't tell if this is possible in Matlab, or how to do so.

 採用された回答

Jonas
Jonas 2021 年 5 月 18 日
編集済み: Jonas 2021 年 5 月 18 日

1 投票

you can combine matlab's system() function with the answer of

2 件のコメント

Colin Raymond
Colin Raymond 2021 年 5 月 18 日
This works perfectly, thank you. The final code is a one-liner -- on a Mac, it's
system('diskutil eject MyExternalDrive')
Jonas
Jonas 2021 年 5 月 19 日
my bad, i assumed you are on a windows system ;)

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeCommunications Toolbox についてさらに検索

製品

リリース

R2019a

質問済み:

2021 年 5 月 18 日

コメント済み:

2021 年 5 月 19 日

Community Treasure Hunt

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

Start Hunting!

Translated by