1台のPCで2つのM​atlabウィンドウ​を起動し、各ウィンド​ウでプログラムを同時​に実行することは可能​でしょうか。

69 visualizaciones (últimos 30 días)
YM
YM el 15 de Feb. de 2024
Comentada: YM el 15 de Feb. de 2024
1台のPCで2つのMatlabウィンドウを起動し、各Matlabウィンドウでプログラムを同時に実行することは可能でしょうか。
計算時間を短縮するために並列計算を行いたいのですが、Parallel Computing Toolboxをすぐに導入出来そうになく、質問をさせていただいた次第です。
具体的には、1時間毎のデータが数年分ありまして、時間毎のデータを読み込んだあと、1日毎にデータ処理をしております。
日を跨いでのデータのやり取りはありません。
そのため、例えば2つMatlabを起動した上で、片方のウィンドウで2020~2021年を計算し、もう一方のウィンドウで2022~2023年を計算すると同時実行が出来そうに思うのですが、変数名が同じだと干渉してしまう可能性があるのでしょうか。
for year=First_year: Last_year
for month=First_month: Last_month
for day=First_day:Last_day
for hour=023
%一日ごとのデータ処理
end %hour
end %day
end %month
end %year
  1 comentario
Dyuman Joshi
Dyuman Joshi el 15 de Feb. de 2024
Yes, you can run 2 instances of MATLAB on the same PC. But both instances will require RAM separetely.
It will be better to run your code as function. And as functions have their own workspaces, there will be no interference of variables.
You could also run your code through profiler to see if there are any bottlenecks in your code.
Also, see if you can vectorize any operations, that will improve the performance of your code.

Iniciar sesión para comentar.

Respuesta aceptada

Kojiro Saito
Kojiro Saito el 15 de Feb. de 2024
Editada: Kojiro Saito el 15 de Feb. de 2024
1台で2以上の複数のMATLABを起動するのは可能です。MATLABインスタンスごとにワークスペースは独立していますので、同じ変数名であっても競合しません。
ただ、MATLABを通常起動すると画面表示などでメモリーを多く消費しますので、「-batch」オプションを使って画面無しで実行する方法のほうが適しているかもしれません。
matlab (Windows)のドキュメントにある「-batch statement」です。たとえば、myscript.mというスクリプトを同時に実行するとして、2つコマンドプロンプト(またはターミナル)を起動して、myscript.mがあるフォルダーに移動(cd)してから、下記のようなコマンドを実行します。
matlab -batch myscript
batchで実行するとスクリプトが終了するとMATLABが終了されますが、終了時にワークスペース変数がクリアされてしまうので、スクリプトの中にsaveコマンドなどで処理結果をファイルで保存しておく必要があります。
  1 comentario
YM
YM el 15 de Feb. de 2024
ご教示いただきありがとうございます。インスタンスごとにワークスペースは独立しているのですね。メモリ節約のための方法も大変参考になりました。重ねてお礼申し上げます。

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre 起動と終了 en Help Center y File Exchange.

Productos


Versión

R2019b

Community Treasure Hunt

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

Start Hunting!