FEMM bitmap file saved via Matlab script is damaged.
22 views (last 30 days)
Show older comments
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 Comments
Answers (1)
Shubham
on 28 Aug 2024
Edited: Shubham
on 28 Aug 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:
- 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.
- 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.
- 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.
- Check if both computers are using the same version of FEMM. Different versions might have different behaviors or bugs.
- 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.
0 Comments
See Also
Categories
Find more on Startup and Shutdown in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!