⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dispsymb.m

📁 一个简单的计算器,用MATLAB开发
💻 M
字号:
function y=dispsymb(h,x)
%显示符号
t=get(h,'string');
if isempty(t)~=0
   set(h,'string',x);
else
   pplus=findstr(t,'+');
   pminus=findstr(t,'-');
   pmul=findstr(t,'*');
   pover=findstr(t,'/');
   
   pcos=findstr(t,'cos(');
   psin=findstr(t,'sin(');
   ptan=findstr(t,'tan(');
   patan=findstr(t,'atan(');
   plog=findstr(t,'log(');
   
   prbra=findstr(t,')');
   plbra=findstr(t,'(');
   pcomm=findstr(t,',');
   pdot=findstr(t,'.');
   len=length(t);
   
   if isempty(pplus)~=0
      pplus=-10;
   end
   if isempty(pminus)~=0
      pminus=-10;
   end
   if isempty(pmul)~=0
      pmul=-10;
   end
   if isempty(pover)~=0
      pover=-10;
   end
   
   if isempty(pcos)~=0
      pcos=-10;
   end
   if isempty(psin)~=0
      psin=-10;
   end
   if isempty(ptan)~=0
      ptan=-10;
   end
   if isempty(patan)~=0
      patan=-10;
   end
   if isempty(plog)~=0
      plog=-10;
   end
   
   if isempty(prbra)~=0
      prbra=-10;
   end
   if isempty(plbra)~=0
      plbra=-10;
   end
   if isempty(pdot)~=0
      pdot=-10;
   end
   if isempty(pcomm)~=0
      pcomm=-10;
   end
   
   
   if pplus~=len  & pminus~=len  & pmul~=len & pover~=len ...
         & pcos~=len-3   & psin~=len-3 & ptan~=len-3 & patan~=len-3 ... & len~=1 ...
         & prbra~=len  & plbra~=len  & pdot~=len & pcomm~=len & plog~=len
      vect=isletter(t);
      if (vect(len)==0) & (strcmp('cos(',x)==1 | strcmp(x,'sin(')==1 | strcmp(x,'tan(')==1 | strcmp(x,'atan(')==1 )
          set(h,'string',strcat(t,strcat('*',x)));
      else
          set(h,'string',strcat(t,x));
      end 
   end   
end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -