مثال های کدنویسی متلب (MATLAB)
دسته بندی ( ۳۳ آموزش )
نمایش دسته بندی ها (۳۳ آموزش)

کد متلب (MATLAB) : مثال شماره 8

کدهای متلب :


clear all
close all
clc

%
% Script to check the solution to the soverning
% equation for a simple circuit, i.e. to check
% that
% i = (V/R) * (1 - exp(-R*t/L))
%
% is the solution to the following ODE
%
% di/dt + (R/L) * i - V/L = 0
%
% Step 1: We will use the Symbolics tools; hence,
% define the symbols as follows
%
syms i V R L t
%
% Step 2: Construct the solution for i
%
i = (V/R) * ( 1 - exp(-R*t/L) );
%
% Step 3: Find the derivative of i
%
didt = diff(i,t);
%
% Step 4: Sum the terms in ODE
%
didt + (R/L) * i - V/L;
%
% Step 5: Is the answer ZERO?
%
simple(ans)
%
% Step 6: What is i at t = 0?
%
subs(i,t,0)
%
% REMARK: Both answers are zero; hence,
% the solution is correct and the
% initial condition is correct.
%
% Step 7: To illustrate the behavior of the
% current, plot i vs. t for V/R = 1
% and R/L = 1. The curve illustrates
% the fact that the current approaches
% i = V/R exponentially.
%
V = 1; R = 1; L = 1;
t = 0 : 0.01 : 6;
i = (V/R) * ( 1 - exp(-R.*t/L) );
plot(t,i,'ro'), title('Circuit problem example')
xlabel('time, t'),ylabel('current, i')
%

نتیجه :

کد متلب (MATLAB) : مثال شماره 8

simplify:
 
0
 
 
radsimp:
 
V/(L*exp((R*t)/L)) - V/L - (V*(1/exp((R*t)/L) - 1))/L
 
 
simplify(100):
 
0
 
 
combine(sincos):
 
V/(L*exp((R*t)/L)) - V/L - (V*(1/exp((R*t)/L) - 1))/L
 
 
combine(sinhcosh):
 
V/(L*exp((R*t)/L)) - V/L - (V*(1/exp((R*t)/L) - 1))/L
 
 
combine(ln):
 
V/(L*exp((R*t)/L)) - V/L - (V*(1/exp((R*t)/L) - 1))/L
 
 
factor:
 
0
 
 
expand:
 
0
 
 
combine:
 
V/(L*exp((R*t)/L)) - V/L - (V*(1/exp((R*t)/L) - 1))/L
 
 
rewrite(exp):
 
V/(L*exp((R*t)/L)) - V/L - (V*(1/exp((R*t)/L) - 1))/L
 
 
rewrite(sincos):
 
- V/L + (V*(cos((R*t*sqrt(-1))/L) + sin((R*t*sqrt(-1))/L)*sqrt(-1)))/L - (V*(cos((R*t*sqrt(-1))/L) - 1 + sin((R*t*sqrt(-1))/L)*sqrt(-1)))/L
 
 
rewrite(sinhcosh):
 
(V*(cosh((R*t)/L) - sinh((R*t)/L)))/L - V/L + (V*(sinh((R*t)/L) - cosh((R*t)/L) + 1))/L
 
 
rewrite(tan):
 
- V/L + (V*((tan(-(R*t*sqrt(-1))/(2*L)) + sqrt(-1))/(tan(-(R*t*sqrt(-1))/(2*L)) - sqrt(-1)) + 1))/L - (V*(tan(-(R*t*sqrt(-1))/(2*L)) + sqrt(-1)))/(L*(tan(-(R*t*sqrt(-1))/(2*L)) - sqrt(-1)))
 
 
mwcos2sin:
 
- V/L - (V*(sin((R*t*sqrt(-1))/L)*sqrt(-1) - 2*sin((R*t*sqrt(-1))/(2*L))^2))/L + (V*(- 2*sin((R*t*sqrt(-1))/(2*L))^2 + sin((R*t*sqrt(-1))/L)*sqrt(-1) + 1))/L
 
 
collect(t):
 
V/(L*exp((R*t)/L)) - V/L - (V*(1/exp((R*t)/L) - 1))/L
 
 
ans =
 
0
 
 
ans =
 
0

منبع کدها :

کتاب Essential MATLAB for Engineers and Scientists - صفحه 333 از فایل pdf کتاب

نویسنده علیرضا گلمکانی
شماره کلید 2294
گزینه ها
به اشتراک گذاری (Share) در شبکه های اجتماعی
نظرات 0 0 0

ارسال نظر جدید (بدون نیاز به عضو بودن در وب سایت)

جستجو در کلیدستان، توسط گوگل

جستجو در عنوان کلیدها

دسترسی سریع

کلید
×

شماره کلید


دسته بندی
×

شماره دسته کلید


جستجو
×

جستجو