Borrar filtros
Borrar filtros

How can I run cmg software with an input data file?

17 visualizaciones (últimos 30 días)
Meng Yuan
Meng Yuan el 27 de Mzo. de 2022
Respondida: Shubham el 16 de En. de 2024
I am trying to couple the cmg software with my matlab code. However, I have to manually input the cmg generated data file name when I run the cmg-gem module with the following code:
system("gm201910.exe")
Can I make it automatic?
  1 comentario
Walter Roberson
Walter Roberson el 27 de Mzo. de 2022
Unfortunately most of cmgl.ca requires a user account, including most of their documentation.
I see a hint that there might be a RunSim provided that can take the names of the dataset to process.

Iniciar sesión para comentar.

Respuestas (1)

Shubham
Shubham el 16 de En. de 2024
To automate the process of passing the CMG-generated data file name to the gm201910.exe program from MATLAB, you can use MATLAB's input/output redirection features. Assuming the CMG program accepts the data file name via standard input (stdin), you can create a script or use a command that pipes the file name into the program.
Here's a MATLAB code snippet that automatically provides the data file name to the CMG program:
% Define the name of your CMG data file
dataFileName = 'your_data_file.dat';
% Create a command that echoes the data file name and pipes it into gm201910.exe
commandStr = ['echo ' dataFileName ' | gm201910.exe'];
% Execute the command
status = system(commandStr);
% Check if the execution was successful
if status == 0
disp('CMG program ran successfully.');
else
disp('There was an error running the CMG program.');
end
Replace 'your_data_file.dat' with the actual name of your CMG data file. The echo command is used to pass the data file name to gm201910.exe. The | symbol is a pipe that redirects the output of the echo command to the input of gm201910.exe.
Please note that the exact command might differ based on the operating system you are using. The above example assumes you are on a Windows system. If you are on a Unix-like system (e.g., Linux or macOS), the command syntax might slightly differ.
If gm201910.exe requires a more complex interaction that cannot be handled by a simple echo (for example, multiple inputs or specific timing), you might need to use a more sophisticated method of automation, such as creating an input file with all the required inputs and then redirecting that file into the program, or using a MATLAB script to simulate the interactive inputs.

Categorías

Más información sobre MATLAB en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by