FEMM bitmap file saved via Matlab script is damaged.

11 visualizaciones (últimos 30 días)
Bence
Bence el 19 de Mayo de 2023
Editada: Shubham el 28 de Ag. de 2024
Hello!
I would like to save the resulting picture of a FEMM simulation through a Matlab script. The corresponding part of my script is the following:
a='probastring%d.png';
filename=sprintf(a,alpha);
mo_showdensityplot(1,0,2.5,0,'mag');
mo_savebitmap(filename);
This runs in a cycle, because I need pictures of a series of calculations.
The issue is that the file created like this is damaged. I tested the command in the inbuilt lua console, and it works just fine, and obviously changing the fileformat doesn't help. I also put some commands after this part so that the FEMM window doesn't close too soon, but it didn't help either. The funny part is, that my college ran this for me, and on his computer it worked perfectly.
Does anyone have an idea how to solve this issue without reinstalling everything? What could cause such an issue?
Thank you very much:
Bence
  5 comentarios
Bence
Bence el 20 de Mayo de 2023
Tried, didn't work, thanks a lot anyway!
Joachim
Joachim el 8 de Mayo de 2024
Hi Bence, were you able to solve this issue in the meantime?

Iniciar sesión para comentar.

Respuestas (1)

Shubham
Shubham el 28 de Ag. de 2024
Editada: Shubham el 28 de Ag. de 2024
Hi Bence,
When dealing with issues like this, especially when a script works on one machine but not another, there are several troubleshooting steps you can follow to identify and potentially solve the problem:
  1. Ensure that the directory where you're trying to save the images has the appropriate write permissions. If the script doesn't have permission to write to the directory, it could result in corrupted files.
  2. Make sure the file path is correct and that the directory exists. You might want to print the filename variable to confirm it's being set as expected.
  3. Ensure that both environments (yours and your colleague's) have the same Matlab version and configurations. Differences in Matlab settings or installed toolboxes might affect how scripts run.
  4. Check if both computers are using the same version of FEMM. Different versions might have different behaviors or bugs.
  5. If the script is running too fast, the image might not have time to render before being saved. You can try adding a pause before the mo_savebitmap command to ensure the plot is fully rendered. For example:
pause(1); % Pause for 1 second
mo_savebitmap(filename);
6. Sometimes temporary files might be causing issues. Try clearing temporary files or restarting Matlab to see if that helps.

Categorías

Más información sobre Startup and Shutdown en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by