Plot now showing correctly
33 ビュー (過去 30 日間)
古いコメントを表示
I was working on my code like 10 days ago in 2025a, the code is running and the plot is showing correctly. I decided to run again to take some screenshot of my plot but my plot is no longer displaying correctly. If I print the plot, I will see the correct plot on the print dialog but the original plot window is showing up very bad. Screenshot applied. Please any immediate help will be appreciated as this is my school assignment.
My computer is Linux Ubuntu 22.04
clear all; close all; clc;
%% System Parameters
% Physical parameters of the DC motor
Ra = 1.0; % Armature resistance (Ohm)
La = 0.5; % Armature inductance (H)
J = 0.01; % Moment of inertia (Nms^2/rad)
b = 0.1; % Damping coefficient (Nms)
KT = 0.01; % Torque constant (Nm/A)
Ke = 0.01; % Back EMF constant (Nm/A)
K = Ke; % In SI units, Ke = Ki = K
%% Transfer Function Definition
% Open loop transfer function: θ(s)/Ea(s)
% G(s) = K / [(Js + b)(Las + Ra) + K^2]
% Coefficients calculation
num = K;
den_coeff = [J*La, (J*Ra + b*La), (b*Ra + K^2)];
den = den_coeff;
% Create transfer function
G = tf(num, den);
% Display the transfer function
fprintf('Open Loop Transfer Function:\n');
fprintf('G(s) = %.4f / (%.4fs^2 + %.4fs + %.4f)\n', num, den(1), den(2), den(3));
%% Performance Specifications
% Desired specifications:
% - Settling time (Ts) < 2 seconds
% - Percentage Overshoot (PO) < 5%
% - Steady State Error (SSE) < 1%
fprintf('\nDesired Specifications:\n');
fprintf('- Settling time (Ts) < 2 seconds\n');
fprintf('- Percentage Overshoot (PO) < 5%%\n');
fprintf('- Steady State Error (SSE) < 1%%\n\n');
%% Step 1: Open Loop Response
fprintf('=== STEP 1: OPEN LOOP RESPONSE ===\n');
figure(1);
[y1, t1] = step(G);
plot(t1, y1, 'b-', 'LineWidth', 2);
title('Open Loop Step Response');
xlabel('Time (seconds)');
ylabel('Angular Position (rad)');
grid on;
% Calculate performance metrics for open loop
stepinfo_ol = stepinfo(G);
fprintf('Open Loop Performance:\n');
fprintf('Rise Time (Tr): %.4f seconds\n', stepinfo_ol.RiseTime);
fprintf('Settling Time (Ts): %.4f seconds\n', stepinfo_ol.SettlingTime);
fprintf('Peak Overshoot: %.2f%%\n', stepinfo_ol.Overshoot);
% Steady state error calculation (for unit step)
% For Type 0 system: ess = 1/(1+Kp) where Kp = lim s->0 G(s)
Kp_ol = dcgain(G);
ess_ol = 1/(1+Kp_ol) * 100; % Convert to percentage
fprintf('Steady State Error: %.2f%%\n', ess_ol);
fprintf('Comments: Open loop system is unstable or has poor performance\n\n');
Bad Plot

Print Dialog

7 件のコメント
Omar
2025 年 10 月 24 日
移動済み: Dyuman Joshi
2025 年 10 月 24 日
Did you solved it, I have the same problem with Matlab R2025b
回答 (1 件)
IBE PETER
2025 年 10 月 29 日
移動済み: Walter Roberson
2025 年 10 月 29 日
I was able to solve it by using a different linewidth in the plot command. plot(t1, y1, 'b-', 'LineWidth', 2); Change that 2 to like 0.5
1 件のコメント
DGM
2025 年 10 月 30 日
This appears to be a known bug:
I can't find anything in the bug reports though.
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
