FEMM bitmap file saved via Matlab script is damaged.
19 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(1 个)
Shubham
2024-8-28
编辑:Shubham
2024-8-28
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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Startup and Shutdown 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!