How do I write the following functions on Matlab x(t) = 2tcos(pi*t) , y(t) = 2sin(pi*t)

7 visualizaciones (últimos 30 días)
I keep getting error using * and other errors
  1 comentario
Steven Lord
Steven Lord el 2 de Mzo. de 2024
These functions didn't exist when the question was originally asked (they were introduced in release R2018b) but the sinpi and cospi functions may be of use.

Iniciar sesión para comentar.

Respuesta aceptada

KSSV
KSSV el 21 de Sept. de 2016
t = 0:0.1:60 ;
x = 2*t.*cos(pi*t) ;
y = 2*sin(pi*t) ;
  2 comentarios
Khalid Tewfik
Khalid Tewfik el 21 de Sept. de 2016
this is what I have t = 0:.1:2; x1 = 2*t.*cos(pi*t); y1 = 2*sin(pi*t); plot(x1,y1) but i'm still getting the error message Error using * Inner matrix dimensions must agree.
Error in plotting (line 8) x1 = 2*t*cos(pi*t);
KSSV
KSSV el 21 de Sept. de 2016
It should work.....you clear space and try..

Iniciar sesión para comentar.

Más respuestas (2)

Adam
Adam el 21 de Sept. de 2016
t = linspace( 0, 2*pi, 100 );
x = 2 * t .* cos( pi * t );
y = 2 * sin( pi * t );
  2 comentarios
Khalid Tewfik
Khalid Tewfik el 21 de Sept. de 2016
this is what I have t = 0:.1:2; x1 = 2*t.*cos(pi*t); y1 = 2*sin(pi*t); plot(x1,y1) but i'm still getting the error message Error using * Inner matrix dimensions must agree.
Error in plotting (line 8) x1 = 2*t*cos(pi*t);
John D'Errico
John D'Errico el 3 de Mzo. de 2024
@Khalid Tewfik - too late for this response for you, but you need to see that you used the expression:
2*t*cos(pi*t)
Do you see you used the * operator, instead of the .* operator? The difference if important in MATLAB.

Iniciar sesión para comentar.


MD.AL-AMIN
MD.AL-AMIN el 2 de Mzo. de 2024
Editada: Walter Roberson el 3 de Mzo. de 2024
% Define the signal function
X = @(t) 5 * sin(2*pi*t) .* cos(pi*t - 8);
% Define the range of t
t = linspace(0, 20, 1000); % Adjust the number of points for desired resolution
% Plot the signal
figure;
plot(t, X(t));
% Label axes and title
xlabel('t');
ylabel('X(t)');
title('Signal X(t)');
% Adjust axis limits and grid (optional)
xlim([0, 20]); % Set appropriate x-axis limits
ylim([-5, 5]); % Set appropriate y-axis limits
grid on;

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by