Plot now showing correctly
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 secondsn’);
fprintf(‘- Percentage Overshoot (PO) < 5%%n’);
fprintf(‘- Steady State Error (SSE) < 1%%nn’);
%% 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 secondsn’, stepinfo_ol.RiseTime);
fprintf(‘Settling Time (Ts): %.4f secondsn’, 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 performancenn’);
Bad Plot
Print DialogI 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 secondsn’);
fprintf(‘- Percentage Overshoot (PO) < 5%%n’);
fprintf(‘- Steady State Error (SSE) < 1%%nn’);
%% 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 secondsn’, stepinfo_ol.RiseTime);
fprintf(‘Settling Time (Ts): %.4f secondsn’, 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 performancenn’);
Bad Plot
Print Dialog 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 secondsn’);
fprintf(‘- Percentage Overshoot (PO) < 5%%n’);
fprintf(‘- Steady State Error (SSE) < 1%%nn’);
%% 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 secondsn’, stepinfo_ol.RiseTime);
fprintf(‘Settling Time (Ts): %.4f secondsn’, 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 performancenn’);
Bad Plot
Print Dialog matlab, plotting MATLAB Answers — New Questions