Help! plotting i(t) vs t.

조회 수: 21 (최근 30일)
David Perez Ramos
David Perez Ramos 2015년 5월 6일
댓글: David Perez Ramos 2015년 5월 7일
Hello, i got stocked bulding my code for this problem.
a) plot i(t) vs. t, over -pi<t<3pi.
i(t)= {3+5*sin(2*t-pi)+t*exp(-t)}[u(t)-u(t-2*pi)]
b) determine the values for i(t) for t = 0, pi/2, pi and -pi/2
c) evaluate RMS value of i(t)
This is what I have so far:
% Script file : sym _ analysis _ RLC
% Analysis of an RLC series circuit
% where the current is iamps i(t)= {3+5*sin(2*t-pi)+t*exp(-t)}[u(t)-u(t-2*pi)]
% R=2K Ohms, L=3mH, and C=1 microF
function i(t) = ?????
u = double(t>=0);
echo off;
iamps= {3+5*sin(2*t-pi)+t*exp(-t)}*(u(t)-u(t-2*pi));
figure(1)
subplot(2,2,1)
ezplot(iamps)
title('i(t) vs.t');
ylabel('Amplitude (amps)');
grid on
ALL advice will be really appreciated.
Thanks.
  댓글 수: 2
Stephen23
Stephen23 2015년 5월 6일
편집: Stephen23 2015년 5월 6일
The first and most important advice is to format your code! In its current form it is unreadable. Please edit your question, select the code-text and then press the {} Code button above textbox. Simple!
Or, if you want to do it by hand, just put two-spaces at the start of each code line.
David Perez Ramos
David Perez Ramos 2015년 5월 6일
편집: Walter Roberson 2015년 5월 7일
Sorry did not realize how it was written on the preview. it is readable now.
thanks.

댓글을 달려면 로그인하십시오.

채택된 답변

Walter Roberson
Walter Roberson 2015년 5월 6일
You cannot list a subscripted variable on the "function" line of a definition.
function iamps = i(t)
You also need to change the {} to ()
iamps = (3+5*sin(2*t-pi)+t*exp(-t))*(u(t)-u(t-2*pi)); %{} became ()
If you are planning to pass a vector of t in, then you need to convert the * into .* in order to vectorize-- In MATLAB, * is algebraic matrix multiplication, not element-by-element multiplication.
iamps = (3+5*sin(2*t-pi)+t.*exp(-t)).*(u(t)-u(t-2*pi)); %vectorize as well
  댓글 수: 3
David Perez Ramos
David Perez Ramos 2015년 5월 7일
Thanks for the help. I did what you said. But how to h define U(t)? Use Heaviside?
David Perez Ramos
David Perez Ramos 2015년 5월 7일
Thank you. I will try it now.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by