Super Calculator(matlab计算器!)
- 格式:doc
- 大小:116.50 KB
- 文档页数:16
如何在Matlab中进行高性能计算与加速如何在Matlab中进行高性能计算与加速?引言:Matlab是一种被广泛应用于科学和工程领域的高级数值计算环境和编程语言。
它提供了许多内置的函数和工具箱,使得科学家和工程师能够方便地进行数据分析、模拟、建模和可视化。
然而,由于Matlab是一种解释型语言,其执行效率较低,对于大规模的计算任务来说,可能会面临较长的运行时间。
在本文中,我将介绍一些在Matlab中进行高性能计算和加速的技巧和方法。
一、向量化计算在Matlab中,向量化是一种重要的优化技巧。
传统的for循环在执行计算时,每次只操作一个元素,而向量化的计算则可以同时对整个数组进行操作,从而避免了循环的开销。
例如,对于一个多维数组A,我们可以使用A.*B来实现逐元素的乘法运算,而不必使用for循环逐个元素相乘。
通过向量化计算,可以大大提高计算效率。
二、合理使用矩阵运算矩阵运算在Matlab中有很高的效率,并且各种工具箱中也提供了许多优化过的矩阵运算函数。
因此,合理利用矩阵运算可以加速Matlab程序的执行。
例如,使用矩阵乘法运算A*B,比使用for循环逐个元素相乘更高效。
此外,Matlab还提供了一些专门用于矩阵运算的函数,如eig、inv、det等,可以更方便地进行矩阵分解、求逆和行列式计算等。
三、使用并行计算在现代计算机中,多核处理器已经成为主流。
为了充分利用这些多核处理器的计算能力,Matlab提供了并行计算工具箱。
通过使用这些工具箱,我们可以将计算任务分解成多个子任务,并同时在多个处理器上并行执行。
这样可以大大提高计算效率。
例如,可以使用parfor代替for循环来并行执行for循环中的计算任务。
四、利用Matlab内置的优化工具箱Matlab有一个内置的优化工具箱,可以帮助我们自动寻找计算速度更快的算法。
通过使用这些工具箱中的函数,我们可以对程序进行剖析,找出效率低下的部分,并进行优化。
工具箱提供了各种优化算法和技巧,如减少内存分配、减少运算次数、减小矩阵大小等,从而实现计算的高效执行。
教你快速上手使用MATLAB进行科学计算第一章:MATLAB简介MATLAB是一种高级编程语言和环境,专门用于科学计算和工程应用。
它提供了许多强大的工具和函数,用于数值计算、数据分析和可视化等应用领域。
MATLAB的灵活性和易用性使得它成为许多科学家、工程师和研究人员的首选工具之一。
第二章:MATLAB基本操作在开始使用MATLAB进行科学计算之前,首先需要了解一些基本操作。
在MATLAB的命令窗口中,可以输入各种命令,并进行计算和操作。
例如,可以定义变量、进行数学运算、加载和保存数据等。
此外,MATLAB还提供了图形用户界面(GUI)和脚本文件等功能,方便用户进行更复杂的操作和编程。
第三章:MATLAB数据类型和运算MATLAB支持多种数据类型和运算。
其中,最常用的数据类型是数值类型,如整数、浮点数和复数等。
MATLAB还支持字符串、矩阵、向量和结构体等数据类型,以满足不同的计算需求。
在进行运算时,MATLAB提供了各种算术运算符和逻辑运算符,可用于数值计算、逻辑判断和条件控制等。
第四章:MATLAB函数和脚本编程MATLAB具有强大的函数库,其中包含了大量的数学函数和工具箱,用于解决各种科学计算问题。
用户可以利用这些函数和工具箱,快速、高效地完成复杂的数值计算和数据处理任务。
此外,MATLAB还支持用户自定义函数和脚本编程,使得用户可以根据自己的需求,编写和调试自己的算法和程序。
第五章:MATLAB数据分析和可视化MATLAB提供了许多用于数据分析和可视化的工具和函数。
用户可以使用MATLAB进行数据处理、统计分析、曲线拟合和模型建立等。
MATLAB还支持各种常用图形的绘制和可视化,如二维和三维图形的绘制、图像处理和动画制作等。
这些功能使得MATLAB成为科学研究和工程实践中不可或缺的工具之一。
第六章:MATLAB应用实例在科学计算和工程应用中,MATLAB有着广泛的应用。
下面以数学建模为例,介绍MATLAB在实际应用中的使用方法。
MATLAB大作业班级:姓名:学号:计算器➢题目本题目通过MATLAB的gui程序设计较为简单,在gui设计中主要用到三种控件,文本编辑框(edit text),静态文本框(Static text),命令按钮(push button)。
然后在通过各个按钮的回调函数,实现简单的计算功能。
➢1、功能介绍(1)具有友好的用户图形界面。
实现十进制数的加、减、乘、除、乘方、开方等简单计算。
(2)具有科学计算函数,包括(反)正弦、(反)余弦、(反)正切、(反)余切、开方、指数等函数运行。
(注:三角函数计算的是弧度而不是角度)。
(3)有清除键,能清除操作。
➢2、功能实现程序由两个部分组成:MATLAB代码(.m文件)和GUI图形(.fig)。
程序使用的流程:直接利用图形界面中的按键键入所需数值、运算符等即可得出结果。
备注:软件版本:MATLAB 2011b首先用MATLAB GUI功能,在绘制一个静态文本框和一个文本编辑框,以及33个命令按钮,调整好各控件大小、颜色,整体布局如图所示:(附录中有相关属性修改介绍)然后通过双击各个按钮来改写其属性,在m文件中编写其回调函数,最后在运行调试。
2.1 各功能界面设计GUI设计界面:注:底部边框用(Panel)工具添加,有两种设计顺序。
(1、先加底部边框,再在底部边框上画功能键。
2、先画功能键,布好局,画底框,全选功能键拖动到底框上。
)2.2 各功能模块实现(可根据需要增减功能键)算法设计:1. 数字键设计:0—9以及小数点函数都一样,只是参数不同:例如:按键‘1’响应:global jjtextString = get(handles.text1,'String');if(strcmp(textString,'0.')==1)&(jj==0)set(handles.text1,'String','1') ;elsetextString =strcat(textString,'1');set(handles.text1,'String',textString)endjj=0;2. 四则运算函数:‘+’功能响应:textString = get(handles.text1,'String');textString =strcat(textString,'+');set(handles.text1,'String',textString)‘-’功能响应:textString = get(handles.text1,'String');textString =strcat(textString,'-');set(handles.text1,'String',textString)‘×’功能响应:textString = get(handles.text1,'String');textString =strcat(textString,'*');set(handles.text1,'String',textString)‘÷’功能响应:textString = get(handles.text1,'String');textString =strcat(textString,'/');set(handles.text1,'String',textString)3. 科学计算函数:例如:‘sin’功能响应:textString = get(handles.text1,'String');if(strcmp(textString,'0.')==1)set(handles.text1,'String','0.') ;elsea = strread(textString, '%f');a=sin(a);set(handles.text1,'String',a)end4. 退格键(DEL):通过取屏幕值,计算出其字符长度,然后取其前N-1项的值来实现退格:global jjtextString = get(handles.text1,'String');if(strcmp(textString,'0.')==1)&(jj==0)set(handles.text1,'String','0.') ;elsess=char(textString);l=length(textString);textString=ss(1:l-1);set(handles.text1,'String',textString)endjj=0;5. 清屏键函数(AC):set(handles.text1,'String','0.') ;2.3 各模块程序添加方法选中一个需添加程序的功能键,右击,View Callbacks,Callback,出现如下图所示界面。
matlab gui计算器设计总结设计MATLAB GUI计算器是一项有趣且具有挑战性的任务。
在这个过程中,你需要考虑到用户的需求和体验,以及如何实现这些需求的技术细节。
以下是对此任务的设计总结:1. 需求分析:在设计计算器之前,首先要明确用户的需求。
一个基本的计算器应该能够进行基本的算术运算(加、减、乘、除)以及求平方和平方根等操作。
此外,设计一个友好的用户界面也非常重要,以方便用户理解和使用计算器。
2. 创建GUI界面:MATLAB的图形用户界面(GUI)工具箱可以帮助你创建计算器的用户界面。
你可以使用各种小部件(如按钮、文本框和标签)来创建界面,并通过回调函数来定义小部件的行为。
3. 实现计算器功能:在MATLAB中,你可以使用脚本或函数来实现计算器的功能。
当用户点击按钮时,回调函数将被触发,执行相应的计算,并将结果显示在界面上。
4. 优化用户体验:良好的用户体验是GUI设计的重要方面。
你可以通过调整颜色、字体和布局来改善界面外观,并通过添加错误处理和提示信息来提高程序的易用性。
5. 测试和调试:完成设计后,进行彻底的测试是非常重要的。
检查所有功能是否正常工作,是否有任何错误或异常行为。
此外,通过用户反馈来进一步优化计算器也是一个好主意。
6. 代码组织和可维护性:为了使代码易于理解和维护,应该保持良好的代码组织和注释。
此外,考虑将计算逻辑和GUI代码分离,以方便未来的修改和扩展。
7. 扩展功能:除了基本功能外,还可以考虑添加一些高级功能,如科学计算、三角函数计算等。
这将为用户提供更多选择,并增加计算器的实用价值。
8. 跨平台兼容性:虽然MATLAB主要用于学术和工程领域,但确保GUI计算器在各种操作系统上都能正常工作仍然是一个好习惯。
这可能需要一些额外的测试和调整。
9. 文档和帮助系统:提供详细的文档和帮助信息可以帮助用户更好地理解和使用计算器。
你可以创建一个帮助文件或使用MATLAB的帮助系统来提供这些信息。
calculators翻译基本解释●calculators:计算器●/ˈkælkjʊˌleɪtərz/●名词(n) 计算器变化形式●复数形式:calculators具体用法●名词:o计算器o同义词:computers, devices, machines, tools, instrumentso反义词:manual methods, mental calculation, estimation, guesswork, approximationo例句:●The students were allowed to use calculators during the mathexam to help them solve complex problems. (学生们在数学考试中被允许使用计算器来帮助他们解决复杂问题。
)●Calculators have become an essential tool in both academicand professional settings for performing quick and accurate calculations. (计算器已成为学术和专业环境中进行快速准确计算的必备工具。
)●With the advent of smartphones, many people now usecalculator apps instead of traditional calculators. (随着智能手机的出现,许多人现在使用计算器应用程序而不是传统计算器。
)●Engineers often rely on calculators to ensure precision in theirmeasurements and designs. (工程师通常依赖计算器来确保其测量和设计的精确性。
)●The teacher demonstrated how to use the scientific calculatorto perform trigonometric functions. (老师演示了如何使用科学计算器来执行三角函数。
基于MATLAB的计算器制作从入门到高级项目一、建立GUI框架1,双击MATLAB图标(本实例使用的是MATLAB R2014),打开软件2,打开GUI操作界面。
有两种方式:a、在命令行窗口输入guide,然后点击回车。
b、先点击新建图标,在选择‘图形用户界面’。
得到如下窗口:左上方有两个按钮:‘新建GUI’,‘打开现有GUI’。
对于‘新建GUI’:下方的选择框内有你可以选择建立的GUI类型,对于初学者一般选择第一个。
下方是用来设置保存文件位置的。
对于‘打开现有GUI’:初学者可能会在网上下载一些GUI源程序,使用‘打开现有GUI’,再浏览到文件所在位置便可。
3、构建GUI框架:在选择新建GUI并且确定后,会弹出如下窗口:在窗口的左边会有很多选项,可以一个个拖动编辑框内;是不是发现这些选项发挥的作用刚好就是我们平常打开一个网页或者一个软件进行操作时的选择按钮。
比较常见的有:按钮、单选按钮、拖动条、弹出式菜单等。
看到这里细心地朋友就会发现,MATLAB GUI似乎可以开发出大型软件哦,只要你有足够的想象力,当你从一个小白进阶到一个高手之后,你可以做到的。
本次计算器制作只需要用到静态文本(或者是动态文本)用来做显示器,按钮(用来操作)。
也可以添加一个面板用来修饰。
在拖出的选项上双击,会得出该选项的属性栏,比如说双击一个按钮选项,你会得到:这个属性框比较复杂,没有必要一个个说清楚(有兴趣的可以自己研究,其实理解起来也挺简单的)本次计算器制作,我们只需要知道以下几个:◆a、BackgroundColor取值为颜色的预定义字符或RGB数值;缺省(就是默认的意思)值为浅灰色;◆b、ForegroundColor取值为颜色的预定义字符或RGB数值,该属性定义控件对象标题字符的颜色;缺省值为黑色;◆c、String取值为字符串矩阵或块数组,定义控件对象标题或选项内容;◆d、FontName取值为控件标题等字体的字库名;◆e、FontSize取值为数值,控制字体大小;◆f、Tag取值为字符串,定义了控件的标识值,在任何程序中都可以通过这个标识值控制该控件对象;◆g、Style取值可以是pushbutton(缺省值),radiobutton, checkbox, edit, text, slider,frame, popupmenu 或listbox;项目二、简单加法器的制作1、框架准备‘加法器’:使用静态文本,在 string 处将文本修改为(加法器),在 fontsize可修改字体大小,在BackgroundColor处可修改背景颜色。
科学计算软件MATLAB的高级使用技巧MATLAB是一种强大的科学计算软件,广泛应用于工程、科学、金融、数据分析等领域。
它具备丰富的功能和灵活的编程环境,让用户可以更加高效地完成复杂的数学和计算任务。
本文将介绍一些MATLAB的高级使用技巧,帮助读者更好地利用这个工具。
1. 矢量化运算:MATLAB可以对数组进行矢量化运算,从而提高运算效率。
矢量化运算是指将逐元素循环操作转换为一次性操作,利用底层的数学库实现高效的计算。
比如,当需要对数组的每个元素进行相同的操作时,可以直接对整个数组进行操作,而不需要使用循环语句。
这样,不仅简化了代码,还提高了运算速度。
2. 向量化索引:MATLAB提供了向量化索引的功能,可以使用逻辑表达式来提取数组中满足条件的元素。
这种索引方式不仅简化了代码,还提高了效率。
例如,可以使用逻辑向量来索引数组,返回满足条件的元素,或者将满足条件的元素设置为特定的值。
3. 匿名函数:MATLAB支持使用匿名函数来定义简洁的函数表达式。
匿名函数的定义方式为 @(参数) 表达式,可以在一行代码中定义函数并进行计算。
这种方式特别适合于一些简单的运算或者需要在其他函数内部使用的函数。
4. 符号计算:MATLAB的符号计算功能可以进行符号表达式的推导和求解,提供了符号计算的环境。
通过将变量定义为符号变量,可以进行符号计算、微积分、代数运算等。
这种功能在数学建模、优化问题求解等领域具有重要的应用。
5. 高效的数据处理:MATLAB提供了一系列用于数据处理的函数,可以高效地处理和分析大量数据。
比如,可以使用矩阵运算来实现数据的快速处理和变换,使用内置函数来执行常见的数据分析任务,如排序、过滤、聚合等。
6. 图像处理与可视化:MATLAB在图像处理和可视化方面也有很高的功能。
它提供了丰富的图像处理函数,可以对图像进行滤波、边缘检测、分割等操作。
同时,MATLAB也提供了灵活的可视化功能,可以绘制各种类型的图形,如线图、散点图、柱状图等,以及三维图形和动画。
function varargout = jisuanqi(varargin)% JISUANQI M-file for jisuanqi.fig% JISUANQI, by itself, creates a new JISUANQI or raises the existing % singleton*.%% H = JISUANQI returns the handle to a new JISUANQI or the handle to % the existing singleton*.%% JISUANQI('CALLBACK',hObject,eventData,handles,...) calls the local % function named CALLBACK in JISUANQI.M with the given input arguments. %% JISUANQI('Property','Value',...) creates a new JISUANQI or raises the % existing singleton*. Starting from the left, property value pairs are % applied to the GUI before jisuanqi_OpeningFcn gets called. An% unrecognized property name or invalid value makes property application % stop. All inputs are passed to jisuanqi_OpeningFcn via varargin. %% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one % instance to run (singleton)".%% See also: GUIDE, GUIDATA, GUIHANDLES% Edit the above text to modify the response to help jisuanqi% Last Modified by GUIDE v2.5 20-Jul-2011 09:45:20% Begin initialization code - DO NOT EDITgui_Singleton = 1;gui_State = struct('gui_Name', mfilename, ...'gui_Singleton', gui_Singleton, ...'gui_OpeningFcn', @jisuanqi_OpeningFcn, ...'gui_OutputFcn', @jisuanqi_OutputFcn, ...'gui_LayoutFcn', [] , ...'gui_Callback', []);if nargin && ischar(varargin{1})gui_State.gui_Callback = str2func(varargin{1});endif nargout[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});elsegui_mainfcn(gui_State, varargin{:});end% End initialization code - DO NOT EDIT% --- Executes just before jisuanqi is made visible.function jisuanqi_OpeningFcn(hObject, eventdata, handles, varargin) handles.current_str='';%´ËΪ´æ´¢µ±Ç°µÄ×Ö·û´®handles.L1_str='';handles.L2_str='';%´ËΪ´æ´¢ÉÏÒ»¸öÊý×ÖµÄ×Ö·û´®% This function has no output args, see OutputFcn.% hObject handle to figure% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% varargin command line arguments to jisuanqi (see VARARGIN)% Choose default command line output for jisuanqihandles.output = hObject;% Update handles structureguidata(hObject, handles);% UIWAIT makes jisuanqi wait for user response (see UIRESUME)% uiwait(handles.figure1);% --- Outputs from this function are returned to the command line. function varargout = jisuanqi_OutputFcn(hObject, eventdata, handles) % varargout cell array for returning output args (see VARARGOUT);% hObject handle to figure% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Get default command line output from handles structurevarargout{1} = handles.output;% --- Executes on button press in Number_0.function Number_0_Callback(hObject, eventdata, handles)%Á¬½Óµ±Ç°µÄ×Ö·û´®ºÍ0£¬Èç¹û°´ÁË0¼üµÄ»°¡£handles.current_str=strcat(handles.current_str,'0');handles.L1_str=strcat(handles.L1_str,'0');%ÔÚÊä³öµ±Ç°µÄ×Ö·û´®set(handles.edit1,'String',handles.current_str);guidata(hObject, handles);% hObject handle to Number_0 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% --- Executes on button press in xiaoshudian.function xiaoshudian_Callback(hObject, eventdata, handles)handles.current_str=strcat(handles.current_str,'.');guidata(hObject, handles);%СÊýµã% hObject handle to xiaoshudian (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% --- Executes on button press in jia_jian.function jia_jian_Callback(hObject, eventdata, handles)% hObject handle to jia_jian (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% --- Executes on button press in Number_1.function Number_1_Callback(hObject, eventdata, handles)% hObject handle to Number_1 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)%Á¬½Óµ±Ç°µÄ×Ö·û´®ºÍ1£¬Èç¹û°´ÁË1¼üµÄ»°¡£handles.current_str=strcat(handles.current_str,'1');handles.L1_str=strcat(handles.L1_str,'1');%ÔÚÊä³öµ±Ç°µÄ×Ö·û´®set(handles.edit1,'String',handles.current_str);guidata(hObject, handles);% --- Executes on button press in Number_2.function Number_2_Callback(hObject, eventdata, handles)%Á¬½Óµ±Ç°µÄ×Ö·û´®ºÍ2£¬Èç¹û°´ÁË1¼üµÄ»°¡£handles.current_str=strcat(handles.current_str,'2');handles.L1_str=strcat(handles.L1_str,'2');%ÔÚÊä³öµ±Ç°µÄ×Ö·û´®set(handles.edit1,'String',handles.current_str);guidata(hObject, handles);% hObject handle to Number_2 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)% --- Executes on button press in Number_3.function Number_3_Callback(hObject, eventdata, handles)%Á¬½Óµ±Ç°µÄ×Ö·û´®ºÍ3£¬Èç¹û°´ÁË3¼üµÄ»°¡£handles.current_str=strcat(handles.current_str,'3');handles.L1_str=strcat(handles.L1_str,'3');%ÔÚÊä³öµ±Ç°µÄ×Ö·û´®set(handles.edit1,'String',handles.current_str);guidata(hObject, handles);% hObject handle to Number_3 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)% --- Executes on button press in Number_4.function Number_4_Callback(hObject, eventdata, handles)%Á¬½Óµ±Ç°µÄ×Ö·û´®ºÍ4£¬Èç¹û°´ÁË4¼üµÄ»°¡£handles.current_str=strcat(handles.current_str,'4');handles.L1_str=strcat(handles.L1_str,'4');%ÔÚÊä³öµ±Ç°µÄ×Ö·û´®set(handles.edit1,'String',handles.current_str);guidata(hObject, handles);% hObject handle to Number_4 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)% --- Executes on button press in Number_5.function Number_5_Callback(hObject, eventdata, handles)%Á¬½Óµ±Ç°µÄ×Ö·û´®ºÍ5£¬Èç¹û°´ÁË5¼üµÄ»°¡£handles.current_str=strcat(handles.current_str,'5');handles.L1_str=strcat(handles.L1_str,'5');%ÔÚÊä³öµ±Ç°µÄ×Ö·û´®set(handles.edit1,'String',handles.current_str);guidata(hObject, handles);% hObject handle to Number_5 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)% --- Executes on button press in Number_6.function Number_6_Callback(hObject, eventdata, handles)%Á¬½Óµ±Ç°µÄ×Ö·û´®ºÍ6£¬Èç¹û°´ÁË6¼üµÄ»°¡£handles.current_str=strcat(handles.current_str,'6');handles.L1_str=strcat(handles.L1_str,'6');%ÔÚÊä³öµ±Ç°µÄ×Ö·û´®set(handles.edit1,'String',handles.current_str);guidata(hObject, handles);% hObject handle to Number_6 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)% --- Executes on button press in Number_7.function Number_7_Callback(hObject, eventdata, handles)%Á¬½Óµ±Ç°µÄ×Ö·û´®ºÍ7£¬Èç¹û°´ÁË7¼üµÄ»°¡£handles.current_str=strcat(handles.current_str,'7');handles.L1_str=strcat(handles.L1_str,'7');%ÔÚÊä³öµ±Ç°µÄ×Ö·û´®set(handles.edit1,'String',handles.current_str);guidata(hObject, handles);% hObject handle to Number_7 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)% --- Executes on button press in Number_8.function Number_8_Callback(hObject, eventdata, handles)%Á¬½Óµ±Ç°µÄ×Ö·û´®ºÍ8£¬Èç¹û°´ÁË8¼üµÄ»°¡£handles.current_str=strcat(handles.current_str,'8');handles.L1_str=strcat(handles.L1_str,'8');%ÔÚÊä³öµ±Ç°µÄ×Ö·û´®set(handles.edit1,'String',handles.current_str);guidata(hObject, handles);% hObject handle to Number_8 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)% --- Executes on button press in Number_9.function Number_9_Callback(hObject, eventdata, handles)%Á¬½Óµ±Ç°µÄ×Ö·û´®ºÍ9£¬Èç¹û°´ÁË9¼üµÄ»°¡£handles.current_str=strcat(handles.current_str,'9');handles.L1_str=strcat(handles.L1_str,'9');%ÔÚÊä³öµ±Ç°µÄ×Ö·û´®set(handles.edit1,'String',handles.current_str);guidata(hObject, handles);% hObject handle to Number_9 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)% --- Executes on button press in jiahao.function jiahao_Callback(hObject, eventdata, handles)handles.current_str=strcat(handles.current_str,'+');set(handles.edit1,'String',handles.current_str);guidata(hObject, handles);% hObject handle to jiahao (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)% --- Executes on button press in denghao.function denghao_Callback(hObject, eventdata, handles)st = get(handles.edit1,'String');%¼ÆËã½á¹û£¬²¢´æ·Åµ½µÚ¶þ¸ö±à¼-¿òÖС£val = eval(st);s = num2str(val);set(handles.edit2,'String',s);guidata(hObject, handles);% hObject handle to denghao (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)% --- Executes on button press in jianhao.function jianhao_Callback(hObject, eventdata, handles)handles.current_str=strcat(handles.current_str,'-');set(handles.edit1,'String',handles.current_str);guidata(hObject, handles);% hObject handle to jianhao (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)% --- Executes on button press in X_daoshu.function X_daoshu_Callback(hObject, eventdata, handles)handles.current_str=strcat(handles.current_str,'\1');set(handles.edit1,'String',handles.current_str);guidata(hObject, handles);% hObject handle to X_daoshu (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)% --- Executes on button press in chenghao.function chenghao_Callback(hObject, eventdata, handles)handles.current_str=strcat(handles.current_str,'*');set(handles.edit1,'String',handles.current_str);guidata(hObject, handles);% hObject handle to chenghao (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)% --- Executes on button press in baifenhao.function baifenhao_Callback(hObject, eventdata, handles)handles.current_str=strcat(handles.current_str,'/100');set(handles.edit1,'String',handles.current_str);guidata(hObject, handles);handles.L2_str=handles.L1_str;handles.L1_str = '';% hObject handle to baifenhao (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)% --- Executes on button press in chuhao.function chuhao_Callback(hObject, eventdata, handles)handles.current_str=strcat(handles.current_str,'/');set(handles.edit1,'String',handles.current_str);guidata(hObject, handles);% hObject handle to chuhao (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)% --- Executes on button press in Sqrt.function Sqrt_Callback(hObject, eventdata, handles)handles.current_str=strcat(handles.current_str,'sqrt');handles.L1_str=strcat(handles.L1_str,'sqrt');%ÔÚÊä³öµ±Ç°µÄ×Ö·û´®set(handles.edit1,'String',handles.current_str);guidata(hObject, handles);% hObject handle to Sqrt (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)% --- Executes on button press in X_lifang.function X_lifang_Callback(hObject, eventdata, handles)handles.current_str=strcat(handles.current_str,'^3');set(handles.edit1,'String',handles.current_str);guidata(hObject, handles);% hObject handle to X_lifang (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)% --- Executes on button press in x_pingfang.function x_pingfang_Callback(hObject, eventdata, handles)handles.current_str=strcat(handles.current_str,'^2');set(handles.edit1,'String',handles.current_str);guidata(hObject, handles);% hObject handle to x_pingfang (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)% --- Executes on button press in zhengqie.function zhengqie_Callback(hObject, eventdata, handles)handles.current_str=strcat(handles.current_str,'tan');handles.L1_str=strcat(handles.L1_str,'tan');%ÔÚÊä³öµ±Ç°µÄ×Ö·û´®set(handles.edit1,'String',handles.current_str);guidata(hObject, handles);% hObject handle to zhengqie (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)% --- Executes on button press in zhengxian.function zhengxian_Callback(hObject, eventdata, handles)handles.current_str=strcat(handles.current_str,'sin');handles.L1_str=strcat(handles.L1_str,'sin');%ÔÚÊä³öµ±Ç°µÄ×Ö·û´®set(handles.edit1,'String',handles.current_str);guidata(hObject, handles);% hObject handle to zhengxian (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)% --- Executes on button press in CE.function CE_Callback(hObject, eventdata, handles)% hObject handle to CE (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)% --- Executes on button press in C.function C_Callback(hObject, eventdata, handles)% hObject handle to C (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) handles.current_str = '';set(handles.edit1,'String','0.');set(handles.edit2,'String','0.');guidata(hObject, handles);% --- Executes on button press in Backspace.function Backspace_Callback(hObject, eventdata, handles)% hObject handle to Backspace (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)s1 = handles.current_str;handles.current_str = s1(1:length(s1)-1);set(handles.edit1,'String',handles.current_str);guidata(hObject, handles);function edit1_Callback(hObject, eventdata, handles)% hObject handle to edit1 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Hints: get(hObject,'String') returns contents of edit1 as text% str2double(get(hObject,'String')) returns contents of edit1 as a double% --- Executes during object creation, after setting all properties. function edit1_CreateFcn(hObject, eventdata, handles)% hObject handle to edit1 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows.% See ISPC and COMPUTER.if ispc && isequal(get(hObject,'BackgroundColor'),get(0,'defaultUicontrolBackgroundColor'))set(hObject,'BackgroundColor','white');endif ispcset(hObject,'BackgroundColor','white');elseset(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')) ;end% --- Executes on button press in shujujiazai.function shujujiazai_Callback(hObject, eventdata, handles)% hObject handle to shujujiazai (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)global YSData;[filename,pathname,FILTERINDEX]=uigetfile({'*.xls';'*.dat';'*.*'},'Ñ¡ÔñÊý¾ÝÎļþ');if(FILTERINDEX==0)return;endstr_filename=[pathname,filename];fid=fopen(str_filename,'rt');if(fid==-1)errordlg('Open file error!','Open error');return;endYSData=xlsread(str_filename);set(handles.lujingxianshi,'String',str_filename);set(handles.tuxingxianshi,'Enable','on');function lujingxianshi_Callback(hObject, eventdata, handles)% hObject handle to lujingxianshi (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)set(handles.lujingxianshi,'String',pathname);% Hints: get(hObject,'String') returns contents of lujingxianshi as text % str2double(get(hObject,'String')) returns contents of lujingxianshi as a double% --- Executes during object creation, after setting all properties. function lujingxianshi_CreateFcn(hObject, eventdata, handles)% hObject handle to lujingxianshi (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows.% See ISPC and COMPUTER.if ispc && isequal(get(hObject,'BackgroundColor'),get(0,'defaultUicontrolBackgroundColor'))set(hObject,'BackgroundColor','white');end% --- Executes on button press in zhuxingtu.function zhuxingtu_Callback(hObject, eventdata, handles)% hObject handle to zhuxingtu (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)set(handles.zhuxingtu,'Value',1);set(handles.zhexiantu,'Value',0);set(handles.yuanbingtu,'Value',0);% Hint: get(hObject,'Value') returns toggle state of zhuxingtu% --- Executes on button press in zhexiantu.function zhexiantu_Callback(hObject, eventdata, handles)% hObject handle to zhexiantu (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)set(handles.zhuxingtu,'Value',0);set(handles.zhexiantu,'Value',1);set(handles.yuanbingtu,'Value',0);% Hint: get(hObject,'Value') returns toggle state of zhexiantu% --- Executes on button press in yuanbingtu.function yuanbingtu_Callback(hObject, eventdata, handles)% hObject handle to yuanbingtu (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)set(handles.zhuxingtu,'Value',0);set(handles.zhexiantu,'Value',0);set(handles.yuanbingtu,'Value',1);% Hint: get(hObject,'Value') returns toggle state of yuanbingtu% --- Executes on button press in tuxingxianshi.function tuxingxianshi_Callback(hObject, eventdata, handles)global YSData;%Åжϡ®Í¼ÏñÀàÐÍ¡¯ÏÂ×éºÏ¿òÖеĸ÷µ¥Ñ¡°´Å¥µÄÑ¡ÖÐÇé¿ö£¬²¢´æ´¢ÔÚIndex_rad iobuttonÖÐIndex_radiobutton=get([handles.zhuxingtu,handles.zhexiantu,handles.yuan bingtu],'Value');%½øÐÐͼÐÎÉú³Éif(Index_radiobutton{1}==1)bar(YSData);title('¸÷Êý¾ÝÖ±·½Í¼');endif(Index_radiobutton{2}==1)plot(YSData);title('¸÷Êý¾ÝÕÛÏßͼ');endif(Index_radiobutton{3}==1)pie(YSData);title('¸÷Êý¾ÝÔ²±ýͼ');end% hObject handle to tuxingxianshi (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% global YSData;% --- Executes during object creation, after setting all properties. function tuxingxianshi_CreateFcn(hObject, eventdata, handles)% hObject handle to tuxingxianshi (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns called function edit2_Callback(hObject, eventdata, handles)% hObject handle to edit2 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Hints: get(hObject,'String') returns contents of edit2 as text% str2double(get(hObject,'String')) returns contents of edit2 as a double% --- Executes during object creation, after setting all properties. function edit2_CreateFcn(hObject, eventdata, handles)% hObject handle to edit2 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows.% See ISPC and COMPUTER.if ispc && isequal(get(hObject,'BackgroundColor'),get(0,'defaultUicontrolBackgroundColor'))set(hObject,'BackgroundColor','white');end% --- Executes on button press in Quit.function Quit_Callback(hObject, eventdata, handles)% hObject handle to Quit (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)close(gcf);% --- Executes during object deletion, before destroying properties. function zhengxian_DeleteFcn(hObject, eventdata, handles)% hObject handle to zhengxian (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)function edit3_Callback(hObject, eventdata, handles)% hObject handle to edit3 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Hints: get(hObject,'String') returns contents of edit3 as text% str2double(get(hObject,'String')) returns contents of edit3 as a double% --- Executes during object creation, after setting all properties. function edit3_CreateFcn(hObject, eventdata, handles)% hObject handle to edit3 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows.% See ISPC and COMPUTER.if ispc && isequal(get(hObject,'BackgroundColor'),get(0,'defaultUicontrolBackgroundColor'))set(hObject,'BackgroundColor','white');end。
Matlab技术高级功能介绍Matlab是一款广泛应用于科学计算和工程领域的软件,它提供了许多强大的功能和工具,使得用户能够更加高效地进行数据处理、图像处理、算法设计等任务。
本文将介绍Matlab的一些高级功能,包括符号计算、并行计算、仿真和优化等方面。
一、符号计算Matlab提供的符号计算功能是其与其他计算软件的重要区别之一。
符号计算可以让用户处理代数方程、微积分等数学问题,而不仅仅是数值计算。
Matlab中的符号计算工具箱可以通过定义符号变量、表达式和方程式来解决复杂的代数问题。
用户可以进行符号运算、求导、积分等操作,并得到符合数学表达式的解。
符号计算的一个典型应用是解方程。
在Matlab中,用户可以使用solve函数来求解一元或多元方程。
例如,用户可以定义一个一元方程cos(x) - x = 0,并使用solve函数来求解该方程的解。
符号计算功能还可以用于符号化函数的微分和积分操作。
二、并行计算随着计算机硬件性能的提升,多核处理器已经成为现代计算机的标配。
Matlab 提供了并行计算工具箱,使用户能够利用多核处理器来加速计算过程。
并行计算可以将一个任务拆分成多个小任务,并同时在多个处理器上进行处理,从而提高计算效率。
在Matlab中,可以使用parfor循环来实现并行计算。
parfor循环与传统的for 循环类似,但是可以在多个处理器上并行执行迭代。
通过使用parfor循环,可以同时对多个数据进行处理,从而缩短计算时间。
并行计算在大规模数据处理、图像处理以及模拟仿真等领域中有广泛应用。
三、仿真Matlab提供了一系列强大的仿真工具,使用户能够模拟和验证各种系统和过程。
仿真是通过建立数学模型,模拟实际系统在不同条件下的行为。
Matlab的仿真工具箱包括控制系统仿真、通信系统仿真、电力系统仿真等各个领域的仿真工具。
例如,在控制系统仿真中,用户可以建立连续或离散的控制系统模型,然后使用Matlab的仿真工具进行系统响应分析、稳定性分析等。
MATLAB科学计算工具入门指南第一章:MATLAB的介绍MATLAB是一款面向科学计算和工程应用的高级编程语言和环境。
它拥有强大的数值计算、矩阵处理和图形可视化能力,广泛应用于各个学科领域的科学计算和工程问题求解。
本章将为读者介绍MATLAB的基本概念和特点,以及如何安装和启动MATLAB环境。
第二章:MATLAB的基本语法本章将介绍MATLAB的基本语法,包括变量的定义与赋值、运算符的使用、条件判断和循环结构等。
通过对MATLAB语法的学习,读者将能够掌握基本的编程技巧和逻辑思维方式。
第三章:向量和矩阵运算MATLAB中矩阵和向量的处理是其最强大的功能之一。
本章将着重介绍MATLAB中矩阵和向量的运算、操作和应用,包括矩阵乘法、转置、求逆、切片等。
通过学习本章内容,读者将能够灵活地利用MATLAB进行矩阵和向量的处理,从而更高效地解决实际问题。
第四章:数据可视化MATLAB拥有强大的数据可视化功能,可以方便地绘制各种类型的图形。
本章将介绍MATLAB中绘图的基本方法和技巧,包括常见的二维和三维图形的绘制、图像的处理和显示等。
通过学习本章内容,读者将能够利用MATLAB绘制各种图形,直观地展示数据和结果。
第五章:数值计算与优化MATLAB在数值计算和优化领域也有很好的表现。
本章将介绍MATLAB中的数值计算和优化方法,包括数值积分、常微分方程求解、最优化问题求解等。
通过学习本章内容,读者将能够利用MATLAB进行高效的数值计算和优化,提高问题的求解精度和效率。
第六章:MATLAB与外部工具的集成MATLAB可以与其他工具和编程语言进行集成,实现更强大的功能。
本章将介绍MATLAB与其他常用工具和语言(如C++、Python等)的集成方法和技巧,以及如何利用MATLAB进行数据交互和接口开发。
通过学习本章内容,读者将能够充分利用MATLAB与外部工具的组合优势,提高工作效率和计算能力。
第七章:MATLAB的应用案例本章将介绍MATLAB在各个学科领域的应用案例,包括工程、物理、生物、金融等。
function varargout = caculator(varargin)% CACULATOR M-file for caculator.fig% CACULATOR, by itself, creates a new CACULATOR or raises the existing% singleton*.%% H = CACULATOR returns the handle to a new CACULATOR or the handle to% the existing singleton*.%% CACULATOR('CALLBACK',hObject,eventData,handles,...) calls the local% function named CALLBACK in CACULATOR.M with the given input arguments. %% CACULATOR('Property','Value',...) creates a new CACULATOR or raises the % existing singleton*. Starting from the left, property value pairs are % applied to the GUI before caculator_OpeningFunction gets called. An% unrecognized property name or invalid value makes property application % stop. All inputs are passed to caculator_OpeningFcn via varargin.%% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one% instance to run (singleton)".%% See also: GUIDE, GUIDATA, GUIHANDLES% Edit the above text to modify the response to help caculator% Last Modified by GUIDE v2.5 03-Aug-2010 23:14:49% Begin initialization code - DO NOT EDITgui_Singleton = 1;gui_State = struct('gui_Name', mfilename, ...'gui_Singleton', gui_Singleton, ...'gui_OpeningFcn', @caculator_OpeningFcn, ...'gui_OutputFcn', @caculator_OutputFcn, ...'gui_LayoutFcn', [] , ...'gui_Callback', []);if nargin && ischar(varargin{1})gui_State.gui_Callback = str2func(varargin{1});endif nargout[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});elsegui_mainfcn(gui_State, varargin{:});end% End initialization code - DO NOT EDIT% --- Executes just before caculator is made visible.function caculator_OpeningFcn(hObject, eventdata, handles, varargin)% This function has no output args, see OutputFcn.% hObject handle to figure% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% varargin command line arguments to caculator (see VARARGIN)% Choose default command line output for caculatorhandles.output = hObject;% Update handles structureguidata(hObject, handles);% UIWAIT makes caculator wait for user response (see UIRESUME)% uiwait(handles.figure1);% --- Outputs from this function are returned to the command line.function varargout = caculator_OutputFcn(hObject, eventdata, handles)% varargout cell array for returning output args (see VARARGOUT);% hObject handle to figure% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Get default command line output from handles structurevarargout{1} = handles.output;function edit1_Callback(hObject, eventdata, handles)% hObject handle to edit1 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Hints: get(hObject,'String') returns contents of edit1 as text% str2double(get(hObject,'String')) returns contents of edit1 as a double% --- Executes during object creation, after setting all properties.function edit1_CreateFcn(hObject, eventdata, handles)% hObject handle to edit1 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns called% Hint: edit controls usually have a white background on Windows.% See ISPC and COMPUTER.if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))set(hObject,'BackgroundColor','white');end% --- Executes on button press in pushbutton1.function pushbutton1_Callback(hObject, eventdata, handles)% hObject handle to pushbutton1 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)%button"1",按键1global jj;textString = get(handles.text1,'String');if(strcmp(textString,'0.')==1)&jj==0;set(handles.text1,'String','1');elsetextString=strcat(textString,'1');set(handles.text1,'String',textString)endjj=0;guidata(hObject, handles)% --- Executes on button press in pushbutton2.function pushbutton2_Callback(hObject, eventdata, handles)% hObject handle to pushbutton2 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)global jj;textString = get(handles.text1,'String');if(strcmp(textString,'0.')==1)&jj==0;set(handles.text1,'String','2');elsetextString=strcat(textString,'2');set(handles.text1,'String',textString)endjj=0;guidata(hObject, handles)% --- Executes on button press in pushbutton3.function pushbutton3_Callback(hObject, eventdata, handles)% hObject handle to pushbutton3 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)global jj;textString = get(handles.text1,'String');if(strcmp(textString,'0.')==1)&jj==0;set(handles.text1,'String','3');elsetextString=strcat(textString,'3');set(handles.text1,'String',textString)endjj=0;guidata(hObject, handles)% --- Executes on button press in pushbutton4.function pushbutton4_Callback(hObject, eventdata, handles)% hObject handle to pushbutton4 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)global jj;textString = get(handles.text1,'String');if(strcmp(textString,'0.')==1)&jj==0;set(handles.text1,'String','4');elsetextString=strcat(textString,'4');set(handles.text1,'String',textString)endjj=0;guidata(hObject, handles)% --- Executes on button press in pushbutton5.function pushbutton5_Callback(hObject, eventdata, handles)% hObject handle to pushbutton5 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)global jj;textString = get(handles.text1,'String');if(strcmp(textString,'0.')==1)&jj==0;set(handles.text1,'String','5');elsetextString=strcat(textString,'5');set(handles.text1,'String',textString)endjj=0;guidata(hObject, handles)% --- Executes on button press in pushbutton6.function pushbutton6_Callback(hObject, eventdata, handles)% hObject handle to pushbutton6 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)global jj;textString = get(handles.text1,'String');if(strcmp(textString,'0.')==1)&jj==0;set(handles.text1,'String','6');elsetextString=strcat(textString,'6');set(handles.text1,'String',textString)endjj=0;guidata(hObject, handles)% --- Executes on button press in pushbutton8.function pushbutton8_Callback(hObject, eventdata, handles)% hObject handle to pushbutton8 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)global jj;textString = get(handles.text1,'String');if(strcmp(textString,'0.')==1)&jj==0;set(handles.text1,'String','7');elsetextString=strcat(textString,'7');set(handles.text1,'String',textString)endjj=0;guidata(hObject, handles)% --- Executes on button press in pushbutton9.function pushbutton9_Callback(hObject, eventdata, handles)% hObject handle to pushbutton9 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)global jj;textString = get(handles.text1,'String');if(strcmp(textString,'0.')==1)&jj==0;set(handles.text1,'String','8');elsetextString=strcat(textString,'8');set(handles.text1,'String',textString)endjj=0;guidata(hObject, handles)% --- Executes on button press in pushbutton10.function pushbutton10_Callback(hObject, eventdata, handles)% hObject handle to pushbutton10 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)global jj;textString = get(handles.text1,'String');if(strcmp(textString,'0.')==1)&jj==0;set(handles.text1,'String','9');elsetextString=strcat(textString,'9');set(handles.text1,'String',textString)endjj=0;guidata(hObject, handles)% --- Executes on button press in pushbutton11.function pushbutton11_Callback(hObject, eventdata, handles)% hObject handle to pushbutton11 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)% + function,加法运算textString = get(handles.text1,'String');textString=strcat(textString,'+');set(handles.text1,'String',textString)guidata(hObject, handles)% --- Executes on button press in pushbutton12.function pushbutton12_Callback(hObject, eventdata, handles)% hObject handle to pushbutton12 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)global jj;textString = get(handles.text1,'String');if(strcmp(textString,'0.')==1)&jj==0;set(handles.text1,'String','0');elsetextString=strcat(textString,'0');set(handles.text1,'String',textString)endjj=0;guidata(hObject, handles)% --- Executes on button press in pushbutton13.function pushbutton13_Callback(hObject, eventdata, handles)% hObject handle to pushbutton13 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)% execute(=) function,执行操作%textString = get(handles.text1,'String');%ans=str2num(textString);textString = get(handles.text1,'String')set(handles.text1,'String',textString)ans = num2str(eval(textString));set(handles.text2,'String',ans)jj=0;guidata(hObject, handles)% --- Executes on button press in pushbutton14.function pushbutton14_Callback(hObject, eventdata, handles)% hObject handle to pushbutton14 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)%Clear function,清除操作set(handles.text1,'String','');guidata(hObject, handles)% --- Executes on button press in pushbutton15.function pushbutton15_Callback(hObject, eventdata, handles)% hObject handle to pushbutton15 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)%"."textString = get(handles.text1,'String');textString=strcat(textString,'.');set(handles.text1,'String',textString)guidata(hObject, handles)function edit2_Callback(hObject, eventdata, handles)% hObject handle to edit2 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Hints: get(hObject,'String') returns contents of edit2 as text% str2double(get(hObject,'String')) returns contents of edit2 as a double% --- Executes during object creation, after setting all properties.function edit2_CreateFcn(hObject, eventdata, handles)% hObject handle to edit2 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns called% Hint: edit controls usually have a white background on Windows.% See ISPC and COMPUTER.if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))set(hObject,'BackgroundColor','white');endfunction edit3_Callback(hObject, eventdata, handles)% hObject handle to edit3 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Hints: get(hObject,'String') returns contents of edit3 as text% str2double(get(hObject,'String')) returns contents of edit3 as a double% --- Executes during object creation, after setting all properties.function edit3_CreateFcn(hObject, eventdata, handles)% hObject handle to edit3 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns called% Hint: edit controls usually have a white background on Windows.% See ISPC and COMPUTER.if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))set(hObject,'BackgroundColor','white');end% --- Executes on button press in pushbutton16.function pushbutton16_Callback(hObject, eventdata, handles)% hObject handle to pushbutton16 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)%back,退格键global jjtextString = get(handles.text1,'String');if(strcmp(textString,'0.')==1)%&(jj==0)set(handles.text1,'String','0.');elsess=char(textString);l=length(textString);textString=ss(1:l-1);set(handles.text1,'String',textString);endjj=0;guidata(hObject, handles)% --- Executes on button press in pushbutton17.function pushbutton17_Callback(hObject, eventdata, handles)% hObject handle to pushbutton17 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)%calculate “+/-”;取反运算textString = get(handles.text1,'String');k=str2num(textString);k=-k;textString=num2str(k);set(handles.text1,'String',textString)guidata(hObject, handles)% --- Executes on button press in pushbutton18.function pushbutton18_Callback(hObject, eventdata, handles)% hObject handle to pushbutton18 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)%calculate -textString = get(handles.text1,'String');textString=strcat(textString,'-');set(handles.text1,'String',textString)guidata(hObject, handles)% --- Executes on button press in pushbutton19.function pushbutton19_Callback(hObject, eventdata, handles)% hObject handle to pushbutton19 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)%calculate *textString = get(handles.text1,'String');textString=strcat(textString,'*');set(handles.text1,'String',textString)guidata(hObject, handles)% --- Executes on button press in pushbutton20.function pushbutton20_Callback(hObject, eventdata, handles)% hObject handle to pushbutton20 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)%calculate /textString = get(handles.text1,'String');textString=strcat(textString,'/');set(handles.text1,'String',textString)guidata(hObject, handles)% --- Executes on button press in pushbutton21.function pushbutton21_Callback(hObject, eventdata, handles)% hObject handle to pushbutton21 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)textString = get(handles.text1,'String');textString=strcat(textString,'(');set(handles.text1,'String',textString)guidata(hObject, handles)% --- Executes on button press in pushbutton22.function pushbutton22_Callback(hObject, eventdata, handles)% hObject handle to pushbutton22 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)textString = get(handles.text1,'String');textString=strcat(textString,')');set(handles.text1,'String',textString)guidata(hObject, handles)% --- Executes on button press in pushbutton23.function pushbutton23_Callback(hObject, eventdata, handles)% hObject handle to pushbutton23 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)%1/x function,求倒数if(str2num(get(handles.text1,'String'))==0)set(handles.text1,'String','Error1:Denominator can not be 0');%分母不能为0 elseresult=1/(str2num(get(handles.text1,'String')));set(handles.text1,'String',num2str(result));end% --- Executes on button press in pushbutton24.function pushbutton24_Callback(hObject, eventdata, handles)% hObject handle to pushbutton24 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)%sqrt function,开方运算result=sqrt(str2num(get(handles.text1,'String')));set(handles.text1,'String',num2str(result));%The implementation for shift between angle and radian,角度/弧度转换具体实现function result=F_shift(ii,hObject, eventdata, handles)if(ii==1)%set(handles.text3,'String','radian')result= str2num(get(handles.text1,'String'));else%set(handles.text3,'String','')result=str2num(get(handles.text1,'String'))*pi/180;end% --- Executes on button press in pushbutton25.function pushbutton25_Callback(hObject, eventdata, handles)% hObject handle to pushbutton25 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)%sin function,正弦函数global ii;global result;result=sin(F_shift(ii,hObject, eventdata, handles));set(handles.text1,'String',num2str(result));set(handles.text2,'String','')% --- Executes on button press in pushbutton26.function pushbutton26_Callback(hObject, eventdata, handles)% hObject handle to pushbutton26 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)%tan function,正切函数%result=tan(str2num(get(handles.text1,'String'))*pi/180);global ii;global result;result=tan(F_shift(ii,hObject, eventdata, handles));set(handles.text1,'String',num2str(result));set(handles.text2,'String','')% --- Executes on button press in pushbutton27.function pushbutton27_Callback(hObject, eventdata, handles)% hObject handle to pushbutton27 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)%lg function,常用对数%result=log10(str2num(get(handles.text1,'String')));%set(handles.text1,'String',num2str(result));textString = get(handles.text1,'String');textString=strcat(textString,'log10');set(handles.text1,'String',textString)guidata(hObject, handles)% --- Executes on button press in pushbutton28.function pushbutton28_Callback(hObject, eventdata, handles)% hObject handle to pushbutton28 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)%x^2 function,平方运算result=(str2num(get(handles.text1,'String')))^2;set(handles.text1,'String',num2str(result));% --- Executes on button press in pushbutton29.function pushbutton29_Callback(hObject, eventdata, handles)% hObject handle to pushbutton29 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)% x^y function,指数运算textString = get(handles.text1,'String');textString=strcat(textString,'^');set(handles.text1,'String',textString)guidata(hObject, handles)% --- Executes on button press in pushbutton30.function pushbutton30_Callback(hObject, eventdata, handles)% hObject handle to pushbutton30 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)%Phase angle function,求向量的角度textString = get(handles.text1,'String');k=str2num(textString);z=str2num(textString);z=angle(z);textString=num2str(z);set(handles.text1,'String',textString)guidata(hObject, handles)% --- Executes on button press in pushbutton31.function pushbutton31_Callback(hObject, eventdata, handles)% hObject handle to pushbutton31 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)%complex number sign function,复数符号textString = get(handles.text1,'String');textString=strcat(textString,'i');set(handles.text1,'String',textString)guidata(hObject, handles)% --- Executes on button press in pushbutton32.function pushbutton32_Callback(hObject, eventdata, handles)% hObject handle to pushbutton32 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)%abslute value function,求绝对值textString = get(handles.text1,'String');z=str2num(textString);z=abs(z);textString=num2str(z);set(handles.text1,'String',textString)guidata(hObject, handles)% --- Executes on button press in pushbutton33.function pushbutton33_Callback(hObject, eventdata, handles)% hObject handle to pushbutton33 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)%shift between angle and radianglobal iiii=~iiif(ii==1)set(handles.text3,'String','radian')elseset(handles.text3,'String','')end。