دوستان من اطلاعاتم در مورد کار با متلب صفره
الان یه برنامه دارم برای رسم منحنی شارژ و دشارژ خازن هست و خطا داره ، ممنون میشم راهنمایی کنین تا خطای برنامه رو برطرف کنم 
کد:
function [v, t] = rectangular_RC(vs, r, c)
tau = r * c;
% First half of the pulse: 0.01 to 0.5 seconds
% Use the correct formula.
t1 = linspace(.01, 0.5, 50);
v1 = vs * (1 - exp(-t1/tau));
% Second half of the pulse: 0.51 to 1 seconds.
% Take into account the max voltage reached.
% Use the appropriate formula.
Vm = v1(end);
t2 = linspace(0.51, 1, 50);
v2 = Vm * exp(-t1/tau);
% Assemble the final vectors to return
t = [t1 t2];
v = [v1 v2];Now, we are going to call the function from our main code, like this
% Given constants
vs = 10;
c = 10e-6;
% Case 1. R = 5k ohms
r1 = 5e3;
[v1, t1] = rectangular_RC(vs, r1, c);
% Case 2. R = 20k ohms
r2 = 20e3;
[v2, t2] = rectangular_RC(vs, r2, c);
% Plot the responses
plot(t1, v1, 'bo', t2, v2, 'r+')
grid on
% Add labels
title('RC circuit - rectangular input')
xlabel('Time (s)')
ylabel('Voltage (V)')
legend(['R_1 = ' num2str(r1)], ...
['R_2 = ' num2str(r2)])
اینم خطایی که داده
کد:
??? function [va, ta] = rectangular_RC(vs, r, c)
|
Error: Function definitions are not permitted at the prompt or in scripts.
خودم هر کاری کردم خطا برطرف نشد