Plot now showing correctly

45 visualizaciones (últimos 30 días)
Samuel
Samuel el 14 de Jul. de 2025
Comentada: DGM el 30 de Oct. de 2025
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 comentarios
Omar
Omar el 24 de Oct. de 2025
Movida: Dyuman Joshi el 24 de Oct. de 2025
Did you solved it, I have the same problem with Matlab R2025b
Sam Chak
Sam Chak el 29 de Oct. de 2025
@Omar, Can you enter "computer" at the Command Window or provide the info about your computer on which MATLAB is running?
computer
ans = 'GLNXA64'

Iniciar sesión para comentar.

Respuestas (1)

IBE PETER
IBE PETER el 29 de Oct. de 2025
Movida: Walter Roberson el 29 de Oct. de 2025

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

Categorías

Más información sobre Programming en Help Center y File Exchange.

Productos


Versión

R2025a

Community Treasure Hunt

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

Start Hunting!

Translated by