On ubuntu, plot() does not create figure

21 ビュー (過去 30 日間)
Geoffrey Rogers
Geoffrey Rogers 2020 年 6 月 14 日
回答済み: Ali 2025 年 1 月 5 日
I just upgraded ubuntu to 20.04 and reinstalled matlab. The plot function does not create a figure window. If I create a figure window with command <figure>, a figure window does appear, but then plot() command does not a draw a plot in it.
  3 件のコメント
Geoffrey Rogers
Geoffrey Rogers 2020 年 6 月 15 日
Thank you Ameer for your response. Unfortunately it still doesn't plot!
Wouter Verstraelen
Wouter Verstraelen 2021 年 2 月 24 日
See this one: it's an annoying (but known) issue
https://www.mathworks.com/matlabcentral/answers/216942-plotting-and-opengl-error-on-linux-how-to-resolve

サインインしてコメントする。

回答 (2 件)

Gayathri
Gayathri 2024 年 12 月 19 日
I understand that you are facing issues in the "plot" function to generate a "figure" in MATLAB on Ubuntu OS.
Please refer to one of the below mentioned workarounds to resolve the issue.
1. Create a file named "java.opts" in the directory where MATLAB is executed (Eg: /usr/local/MATLAB/R2024b/bin/glnxa64) and include the following line.
-Djogl.disable.openglarbcontext=1
2. Run MATLAB from the terminal using the following command to override the graphics driver.
export MESA_LOADER_DRIVER_OVERRIDE=i965; matlab
3. Launch MATLAB with software OpenGL by using the following command.
matlab -softwareopengl
4. Turn off anti-aliasing for figures by setting the "GraphicsSmoothing" property to "off" .
set(gcf, 'GraphicsSmoothing', 'off');
You can also refer to the following MATLAB Answer to learn more about the workarounds.
For more information, refer to the following MathWorks Documentation to learn about ‘Resolving Low-Level Graphics Issues’.
Hope you find this information helpful.

Ali
Ali 2025 年 1 月 5 日
num = [1];
denum = [1 3 1];
g = tf(num, denum);
% Closed-loop system without controller
sys = feedback(g, 1);
figure;
step(sys);
drawnow;
hold on;
title('Step Responses');
xlabel('Time (seconds)');
ylabel('Amplitude');
grid on;
% PID Controller with manual gains
kp = 1;
ki = 1;
kd = 1;
p_manual = pid(kp, ki, kd);
% Closed-loop system with manual PID controller
sys_manual = feedback(p_manual * g, 1);
step(sys_manual);
% PID Tuning
p_tuned = pidtune(g, 'pid');
disp('Tuned PID Gains:');
disp(p_tuned);
% Closed-loop system with tuned PID controller
sys_tuned = feedback(p_tuned * g, 1);
step(sys_tuned);
% Add legend to distinguish responses
legend('Without Controller', 'Manual PID', 'Tuned PID');

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by