最新文章专题视频专题问答1问答10问答100问答1000问答2000关键字专题1关键字专题50关键字专题500关键字专题1500TAG最新视频文章推荐1 推荐3 推荐5 推荐7 推荐9 推荐11 推荐13 推荐15 推荐17 推荐19 推荐21 推荐23 推荐25 推荐27 推荐29 推荐31 推荐33 推荐35 推荐37视频文章20视频文章30视频文章40视频文章50视频文章60 视频文章70视频文章80视频文章90视频文章100视频文章120视频文章140 视频2关键字专题关键字专题tag2tag3文章专题文章专题2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章专题3
当前位置: 首页 - 正文

基于matlab的电路仿真-例子

来源:动视网 责编:小OO 时间:2025-09-24 15:03:44
文档

基于matlab的电路仿真-例子

基于matlab的电路仿真2007-10-2310:03关键词:RC电路仿真,matlab,GUI设计出处:萝卜驿站%基于matlab的电路仿真%萝卜驿站closeall;clear;clc;figure('position',[1714485]);Na=['输入波形[请选择]|输入波形:正弦波|',...        '输入波形:方形波|输入波形:脉冲波'];Ns={'sin','square','pulse'};R=2;  %defaultparameters:resistanc
推荐度:
导读基于matlab的电路仿真2007-10-2310:03关键词:RC电路仿真,matlab,GUI设计出处:萝卜驿站%基于matlab的电路仿真%萝卜驿站closeall;clear;clc;figure('position',[1714485]);Na=['输入波形[请选择]|输入波形:正弦波|',...        '输入波形:方形波|输入波形:脉冲波'];Ns={'sin','square','pulse'};R=2;  %defaultparameters:resistanc
基于matlab的电路仿真

2007-10-23 10:03

关键词: RC电路仿真, matlab, GUI设计

出处: 萝卜驿站

% 基于matlab的电路仿真

% 萝卜驿站

close all;clear;clc;

figure('position',[1  714 485]);

Na=['输入波形[请选择]|输入波形:正弦波|',...

         '输入波形:方形波|输入波形:脉冲波'];

Ns={'sin','square','pulse'};

R=2;   % default parameters: resistance

C=2;   % default parameters: capacitance

f=10; % default parameters: frequency

TAU=R*C;;

tff=10;   % length of time

ts=1/f;   % sampling length

sys1=tf([1],[1,1]);      % systems for integral circuit

sys2=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: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.33],[0.8,0.8],''k'');',...

         'plot([0.33,0.33],[0.74,0.86],''k'');',...

         'plot([0.36,0.36],[0.74,0.86],''k'');',...

         'plot([0.36,0.82],[0.8,0.8],''k'');',...

         'plot([0.6,0.6],[0.8,0.58],''k'');',...

         'plot([0.6,0.6],[0.2,0.42],''k'');',...

         'plot([58,62,62,58,58]/100,[42,42,58,58,42]/100,''k'');',...

         'text(0.33,0.68,''C'');',...

         'text(0.63,0.42,''R'');',...

         'text(0.8,0.5,''U_o'');text(0.1,0.5,''U_i'');hold off;',... 

         'set(gca,''xtick'',[]);set(gca,''ytick'',[]);',...

         'end;axis([0,1,0,1]);']);

a3=axes('position',[0.1,0.1,0.3,0.3]);

pu3=uicontrol(gcf,'style','push',...

     'unit','normalized','position',[0.15,0.43,0.2,0.04],...

     'string','显示输出波形','fontsize',12,...

     'callback',['axes(a3);if KQ==2;lsim(sys1,U,T);',...

         'elseif KQ==3;lsim(sys2,U,T);else,cla;end;']);

uicontrol(gcf,'style','frame',...

     'unit','normalized','position',[0.47,0.13,0.5,0.32],...

     'string','10','BackgroundColor',[0.8,0.8,0.8],...

     'fontsize',16,'fontname','times new roman');

s1=uicontrol(gcf,'style','slider',...

     'unit','normalized','position',[0.55,0.38,0.3,0.03],...

     'Value',0.5,'SliderStep',[0.01 0.01],...

     'callback',['R=1+get(s1,''Value'')*2;',...

         '[U,T]=gensig(st,R*C,tff,1/f);',...

         'set(t1,''string'',num2str(R));']);

uicontrol(gcf,'style','text',...

     'unit','normalized','position',[0.5,0.37,0.05,0.05],...

     'string','R','BackgroundColor',[0.8,0.8,0.8],...

     'fontsize',16,'fontname','times new roman');

t1=uicontrol(gcf,'style','text',...

     'unit','normalized','position',[0.86,0.37,0.1,0.05],...

     'string','2','BackgroundColor',[0.8,0.8,0.8],...

     'fontsize',16,'fontname','times new roman');

s2=uicontrol(gcf,'style','slider',...

     'unit','normalized','position',[0.55,0.28,0.3,0.03],...

     'Value',0.5,'SliderStep',[0.01 0.01],...

     'callback',['C=1+get(s2,''Value'')*2;',...

         '[U,T]=gensig(st,R*C,tff,1/f);',...

         'set(t2,''string'',num2str(C));']);

uicontrol(gcf,'style','text',...

     'unit','normalized','position',[0.5,0.27,0.05,0.05],...

     'string','C','BackgroundColor',[0.8,0.8,0.8],...

     'fontsize',16,'fontname','times new roman');

t2=uicontrol(gcf,'style','text',...

     'unit','normalized','position',[0.86,0.27,0.1,0.05],...

     'string','2','BackgroundColor',[0.8,0.8,0.8],...

     'fontsize',16,'fontname','times new roman');

set(gcf,'NumberTitle','off','MenuBar','none');

set(gcf,'name','基于matlab的电路仿真');

uu=uimenu(gcf,'label','About');

uimenu(uu,'label','Author:Zjliu');

ku=uimenu(gcf,'label','Readme');

kw1=uimenu(gcf,'label','执行顺序:');

kw2=uimenu(gcf,'label','设定参数-->确定波形-->选择电路类型-->输出波形');

set(kw1,'ForegroundColor','r');set(kw2,'ForegroundColor','b');

uicontrol(gcf,'style','text',...

     'unit','normalized','position',[0.5,0.47,0.46,0.05],...

     'string','请选择波形之前改变下面的参数',...

     'BackgroundColor',[0.8,0.8,0.8],...

     'fontsize',16,'fontname','times new roman');     % readme

s3=uicontrol(gcf,'style','slider',...

     'unit','normalized','position',[0.55,0.18,0.3,0.03],...

     'Value',0.5,'SliderStep',[0.01 0.01],...

     'callback',['f=5+get(s3,''Value'')*10;',...

         '[U,T]=gensig(st,R*C,tff,1/f);',...

         'set(t3,''string'',num2str(f));']);

uicontrol(gcf,'style','text',...

     'unit','normalized','position',[0.5,0.17,0.05,0.05],...

     'string','f','BackgroundColor',[0.8,0.8,0.8],...

     'fontsize',16,'fontname','times new roman');

t3=uicontrol(gcf,'style','text',...

     'unit','normalized','position',[0.86,0.17,0.1,0.05],...

     'string','10','BackgroundColor',[0.8,0.8,0.8],...

     'fontsize',16,'fontname','times new roman');

http://hi.baidu.com/nailson/blog/item/d1f20a6c76ce3db0351d4f.html

文档

基于matlab的电路仿真-例子

基于matlab的电路仿真2007-10-2310:03关键词:RC电路仿真,matlab,GUI设计出处:萝卜驿站%基于matlab的电路仿真%萝卜驿站closeall;clear;clc;figure('position',[1714485]);Na=['输入波形[请选择]|输入波形:正弦波|',...        '输入波形:方形波|输入波形:脉冲波'];Ns={'sin','square','pulse'};R=2;  %defaultparameters:resistanc
推荐度:
  • 热门焦点

最新推荐

猜你喜欢

热门推荐

专题
Top