基于matlab的电路仿真-例子
基于matlab的电路仿真
2007-10-23 10:03
关键词: RC电路仿真, matlab, GUI设计出处: 萝卜驿站% 基于matlab的电路仿真% 萝卜驿站close all;clear;clc;figure 'position',[189 89 714 485] ;Na ['输入波形[请选择]|输入波形:正弦波|',... '输入波形:方形波|输入波形:脉冲波'];Ns 'sin','square','pulse' ;
R 2;?? % default parameters: resistanceC 2;?? % default parameters: capacitancef 10; % default parameters: frequency
TAU R*C;;tff 10;?? % length of timets 1/f;?? % sampling length
sys1 tf [1],[1,1] ; % systems for integral circuitsys2 tf [1,0],[1,1] ;??? % systems for differential circuit
a1 axes 'position',[0.1,0.6,0.3,0.3] ;po1 uicontrol gcf,'style','popupmenu',... 'unit','normalized','position',[0.15,0.9,0.2,0.08],... 'string',Na,'fontsize',12,'callback',[] ;set po1,'callback',['KK get po1,''Value'' ;if KK 1;',... 'st char Ns KK-1 ;[U,T] gensig st,R*C,tff,1/f ;',... 'axes a1 ;plot T,U ;ylim [min U -0.5,max U +0.5] ;',... 'end;'] ;Ma ['电路类型[请选择]|电路类型:积分型|电路类型:微分型'];a2 axes 'position',[0.5,0.6,0.3,0.3] ;box on;set gca,'xtick',[] ;set gca,'ytick',[] ;po2 uicontrol gcf,'style','popupmenu',... 'unit','normalized','position',[0.55,0.9,0.2,0.08],... 'string',Ma,'fontsize',12,'callback',[] ;set po2,'callback',['KQ get po2,''Value'' ;axes a2 ;',... 'if KQ 1;cla;elseif KQ 2;',... 'plot 0.14+0.8i+0.02*exp i*[0:.02:8] ,''k'' ;hold on;',... 'plot 0.14+0.2i+0.02*exp i*[0:.02:8] ,''k'' ;',... 'plot 0.84+0.2i+0.02*exp i*[0:.02:8] ,''k'' ;',... 'plot 0.84+0.8i+0.02*exp i*[0:.02:8] ,''k'' ;',... 'plot [0.16,0.82],[0.2,0.2],''k'' ;',... 'plot [0.16,0.3],[0.8,0.8],''k'' ;',... 'plot [3,4,4,3,3]/10,[76,76,84,84,76]/100,''k'' ;',... 'plot [0.4,0.82],[0.8,0.8],''k'' ;',... 'plot [0.6,0.6],[0.8,0.53],''k'' ;',... 'plot [0.6,0.6],[0.2,0.48],''k'' ;',... 'plot [0.55,0.65],[0.53,0.53],''k'' ;',... 'plot [0.55,0.65],[0.48,0.48],''k'' ;',... 'text 0.33,0.7,''R'' ;',... 'text 0.63,0.42,''C'' ;',... 'text 0.8,0.5,''U_o'' ;text 0.1,0.5,''U_i'' ;hold off;',... 'set gca,''xtick'',[] ;set gca,''ytick'',[] ;',... 'else;',... 'plot 0.14+0.8i+0.02*exp i*[0:.02