久久久久久久999_99精品久久精品一区二区爱城_成人欧美一区二区三区在线播放_国产精品日本一区二区不卡视频_国产午夜视频_欧美精品在线观看免费

 找回密碼
 立即注冊(cè)

QQ登錄

只需一步,快速開始

搜索
查看: 3128|回復(fù): 2
打印 上一主題 下一主題
收起左側(cè)

MATLAB GUI界面關(guān)于匯率轉(zhuǎn)換和存儲(chǔ)匯率計(jì)算

[復(fù)制鏈接]
跳轉(zhuǎn)到指定樓層
樓主
這是我之前課程設(shè)計(jì)寫的一段代碼,老師讓自主設(shè)計(jì)我就寫了一個(gè)有關(guān)于匯率轉(zhuǎn)換的,包括很多國家的貨幣之間的匯率轉(zhuǎn)換,還可以用于計(jì)算銀行的存儲(chǔ)的日利息,月利息和年利息。


MATLAB源程序如下:
  1. function varargout = Interest_rate1(varargin)
  2. % INTEREST_RATE1 MATLAB code for Interest_rate1.fig
  3. %      INTEREST_RATE1, by itself, creates a new INTEREST_RATE1 or raises the existing
  4. %      singleton*.
  5. %
  6. %      H = INTEREST_RATE1 returns the handle to a new INTEREST_RATE1 or the handle to
  7. %      the existing singleton*.
  8. %
  9. %      INTEREST_RATE1('CALLBACK',hObject,eventData,handles,...) calls the local
  10. %      function named CALLBACK in INTEREST_RATE1.M with the given input arguments.
  11. %
  12. %      INTEREST_RATE1('Property','Value',...) creates a new INTEREST_RATE1 or raises the
  13. %      existing singleton*.  Starting from the left, property value pairs are
  14. %      applied to the GUI before Interest_rate1_OpeningFcn gets called.  An
  15. %      unrecognized property name or invalid value makes property application
  16. %      stop.  All inputs are passed to Interest_rate1_OpeningFcn via varargin.
  17. %
  18. %      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
  19. %      instance to run (singleton)".
  20. %
  21. % See also: GUIDE, GUIDATA, GUIHANDLES

  22. % Edit the above text to modify the response to help Interest_rate1

  23. % Last Modified by GUIDE v2.5 28-Aug-2016 18:27:40

  24. % Begin initialization code - DO NOT EDIT
  25. gui_Singleton = 1;
  26. gui_State = struct('gui_Name',       mfilename, ...
  27.                    'gui_Singleton',  gui_Singleton, ...
  28.                    'gui_OpeningFcn', @Interest_rate1_OpeningFcn, ...
  29.                    'gui_OutputFcn',  @Interest_rate1_OutputFcn, ...
  30.                    'gui_LayoutFcn',  [] , ...
  31.                    'gui_Callback',   []);
  32. if nargin && ischar(varargin{1})
  33.     gui_State.gui_Callback = str2func(varargin{1});
  34. end

  35. if nargout
  36.     [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
  37. else
  38.     gui_mainfcn(gui_State, varargin{:});
  39. end
  40. % End initialization code - DO NOT EDIT

  41. % --- Executes just before Interest_rate1 is made visible.
  42. function Interest_rate1_OpeningFcn(hObject, eventdata, handles, varargin)
  43. % This function has no output args, see OutputFcn.
  44. % hObject    handle to figure
  45. % eventdata  reserved - to be defined in a future version of MATLAB
  46. % handles    structure with handles and user data (see GUIDATA)
  47. % varargin   command line arguments to Interest_rate1 (see VARARGIN)

  48. % Choose default command line output for Interest_rate1
  49. handles.output = hObject;

  50. % Update handles structure
  51. guidata(hObject, handles);

  52. % UIWAIT makes Interest_rate1 wait for user response (see UIRESUME)
  53. % uiwait(handles.figure1);


  54. % --- Outputs from this function are returned to the command line.
  55. function varargout = Interest_rate1_OutputFcn(hObject, eventdata, handles)
  56. % varargout  cell array for returning output args (see VARARGOUT);
  57. % hObject    handle to figure
  58. % eventdata  reserved - to be defined in a future version of MATLAB
  59. % handles    structure with handles and user data (see GUIDATA)

  60. % Get default command line output from handles structure
  61. varargout{1} = handles.output;


  62. % --- Executes on button press in radiobutton1.
  63. function radiobutton1_Callback(hObject, eventdata, handles)   
  64. % hObject    handle to radiobutton1 (see GCBO)
  65. % eventdata  reserved - to be defined in a future version of MATLAB
  66. % handles    structure with handles and user data (see GUIDATA)

  67. % Hint: get(hObject,'Value') returns toggle state of radiobutton1
  68. global type   
  69. type=1;

  70. % --- Executes on button press in radiobutton2.
  71. function radiobutton2_Callback(hObject, eventdata, handles)
  72. % hObject    handle to radiobutton2 (see GCBO)
  73. % eventdata  reserved - to be defined in a future version of MATLAB
  74. % handles    structure with handles and user data (see GUIDATA)

  75. % Hint: get(hObject,'Value') returns toggle state of radiobutton2
  76. global type
  77. type=2;


  78. % --- Executes on button press in pushbutton1.
  79. function pushbutton1_Callback(hObject, eventdata, handles)
  80. % hObject    handle to pushbutton1 (see GCBO)
  81. % eventdata  reserved - to be defined in a future version of MATLAB
  82. % handles    structure with handles and user data (see GUIDATA)
  83. global money t
  84. t=1;
  85. f1=fopen('money.txt');                       %By reading the text file to input the principal
  86. money=fscanf(f1,'%d');
  87. fclose(f1);                                  %close the file
  88. set(handles.text3,'string',num2str(money));  %Display the value in the static text box
  89. axes(handles.axes1);
  90. title('存款本金');
  91. stem(t,money);


  92. % --- Executes on button press in pushbutton2.
  93. function pushbutton2_Callback(hObject, eventdata, handles)
  94. % hObject    handle to pushbutton2 (see GCBO)
  95. % eventdata  reserved - to be defined in a future version of MATLAB
  96. % handles    structure with handles and user data (see GUIDATA)
  97. global Time Amount Type Name
  98. fid=fopen('Bill.txt');                    %By reading the text file to input the bill
  99. fscanf(fid, '%s %s',2);
  100. Name=fscanf(fid, '%s',1);                 %obtain the user's name
  101. fgetl(fid);                              
  102. fgetl(fid);
  103. Time=[];                                 
  104. Amount=[];
  105. Type=[];
  106. while ~feof(fid);
  107.     Time=[Time,fscanf(fid, '%d ',1)];      %obtain the time of deposit or withdrawals
  108.     Amount=[Amount,fscanf(fid, '%f ',1)];   %obtain the amount of deposit or withdrawals
  109.     Type=[Type,fscanf(fid, '%c ',1)];       %obtain the type of deposit or withdrawals
  110. end
  111. Name
  112. Time
  113. Amount
  114. Type



  115. % --- Executes on selection change in popupmenu1.
  116. function popupmenu1_Callback(hObject, eventdata, handles)
  117. % hObject    handle to popupmenu1 (see GCBO)
  118. % eventdata  reserved - to be defined in a future version of MATLAB
  119. % handles    structure with handles and user data (see GUIDATA)
  120. global e
  121. n=get(handles.popupmenu1,'Value');
  122. e=n;


  123. % Hints: contents = cellstr(get(hObject,'String')) returns popupmenu1 contents as cell array
  124. %        contents{get(hObject,'Value')} returns selected item from popupmenu1


  125. % --- Executes during object creation, after setting all properties.
  126. function popupmenu1_CreateFcn(hObject, eventdata, handles)
  127. % hObject    handle to popupmenu1 (see GCBO)
  128. % eventdata  reserved - to be defined in a future version of MATLAB
  129. % handles    empty - handles not created until after all CreateFcns called

  130. % Hint: popupmenu controls usually have a white background on Windows.
  131. %       See ISPC and COMPUTER.
  132. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  133.     set(hObject,'BackgroundColor','white');
  134. end


  135. % --- Executes on button press in pushbutton3.
  136. function pushbutton3_Callback(hObject, eventdata, handles)
  137. % hObject    handle to pushbutton3 (see GCBO)
  138. % eventdata  reserved - to be defined in a future version of MATLAB
  139. % handles    structure with handles and user data (see GUIDATA)
  140. global e money Rate  Loan_rate
  141. fid=fopen('Data.txt');                   %By reading the text file to obtain the rate of deposit and loan ,exchange rate
  142. fgetl(fid);                              % returns the next line of the specified file, removing the newline characters.
  143. Exchange=[];                             %exchange rate
  144. Rate=[];                                 %the rate of deposit
  145. Loan_rate=[];                            %the rate of loan
  146. while ~feof(fid);
  147.     Rate=[Rate,fscanf(fid, '%f ',1)];
  148.     Exchange=[Exchange,fscanf(fid, '%f ',1)];
  149.     Loan_rate=[Loan_rate,fscanf(fid, '%f ',1)];
  150. end
  151. Exchange_rate=Exchange(e);
  152. amount0=money*Exchange_rate;
  153. set(handles.text4,'string',num2str(amount0));         %Display the converted amount in the static text box
  154. set(handles.text6,'string',num2str(Exchange_rate));  %Display the exchange rate
  155. axes(handles.axes1);
  156. title('外匯匯率');
  157. x=1:1:6;
  158. stem(x,Exchange);

  159. % --- Executes on selection change in popupmenu2.
  160. function popupmenu2_Callback(hObject, eventdata, handles)
  161. % hObject    handle to popupmenu2 (see GCBO)
  162. % eventdata  reserved - to be defined in a future version of MATLAB
  163. % handles    structure with handles and user data (see GUIDATA)

  164. % Hints: contents = cellstr(get(hObject,'String')) returns popupmenu2 contents as cell array
  165. %        contents{get(hObject,'Value')} returns selected item from popupmenu2
  166. global t_deposit
  167. m=get(handles.popupmenu2,'Value');      %Choose the currency
  168. t_deposit=m;


  169. % --- Executes during object creation, after setting all properties.
  170. function popupmenu2_CreateFcn(hObject, eventdata, handles)
  171. % hObject    handle to popupmenu2 (see GCBO)
  172. % eventdata  reserved - to be defined in a future version of MATLAB
  173. % handles    empty - handles not created until after all CreateFcns called

  174. % Hint: popupmenu controls usually have a white background on Windows.
  175. %       See ISPC and COMPUTER.
  176. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  177.     set(hObject,'BackgroundColor','white');
  178. end


  179. % --- Executes on button press in pushbutton4.
  180. function pushbutton4_Callback(hObject, eventdata, handles)
  181. % hObject    handle to pushbutton4 (see GCBO)
  182. % eventdata  reserved - to be defined in a future version of MATLAB
  183. % handles    structure with handles and user data (see GUIDATA)
  184. global Rate type t_deposit money amount1  t_loan Loan_rate
  185. switch type
  186.     case 1
  187.          switch t_loan
  188.              case 1      %loan for one year
  189.                  amount1=(Loan_rate(1)+1)*money;
  190.                  set(handles.text11,'string',num2str(Loan_rate(t_loan)));
  191.                  set(handles.text9,'string',num2str(amount1));
  192.              case {2,3,4,5}    %loan for 2~5 years
  193.                  amount1=(Loan_rate(t_loan)+1)^t_loan*money;
  194.                  set(handles.text11,'string',num2str(Loan_rate(t_loan)));
  195.                  set(handles.text9,'string',num2str(amount1));
  196.              case {6,7,8,9,10} %loan 6~10 years
  197.                  amount1=(Loan_rate(6)+1)^t_loan*money;
  198.                  set(handles.text11,'string',num2str(Loan_rate(6)));
  199.                  set(handles.text9,'string',num2str(amount1));
  200.          end
  201.     case 2
  202.         switch t_deposit
  203.             case 1
  204.                 amount1=(Rate(t_deposit+1)/4.0+1)*money;%Time deposit for three months
  205.             case 2
  206.                 amount1=(Rate(t_deposit+1)/2+1)*money;   %Time deposit for six months
  207.             case 3
  208.                 amount1=(Rate(t_deposit+1)+1)*money;      %Time deposit for one year
  209.             case 4
  210.                 amount1=(Rate(t_deposit+1)+1)*(Rate(4)+1)*money;   %Time deposit for two years
  211.             case 5
  212.                 amount1=(Rate(t_deposit+1)+1)*(Rate(5)+1)*(Rate(5)+1)*money;  %Time deposit for three years
  213.         end
  214.       set(handles.text9,'string',num2str(amount1));%diaplay the principal and interest
  215.       set(handles.text11,'string',num2str(Rate(t_deposit+1)));%display the rate
  216. end
  217. axes(handles.axes2);                %draw the matchstick picture of the diffrent
  218. ……………………

  219. …………限于本文篇幅 余下代碼請(qǐng)從51黑下載附件…………
復(fù)制代碼

所有資料51hei提供下載:
實(shí)驗(yàn)1(Interest Rate).zip (43.95 KB, 下載次數(shù): 18)



分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏 分享淘帖 頂 踩
回復(fù)

使用道具 舉報(bào)

沙發(fā)
ID:393139 發(fā)表于 2018-9-3 19:46 | 只看該作者
太復(fù)雜了,有點(diǎn)看不懂啊,能不能求一個(gè)只有幾種貨幣互相轉(zhuǎn)換的,不要利息部分的,簡單一點(diǎn)就好,學(xué)習(xí)學(xué)習(xí)就好,可以嗎?
回復(fù)

使用道具 舉報(bào)

板凳
ID:393139 發(fā)表于 2018-9-10 19:15 | 只看該作者

太復(fù)雜了,有點(diǎn)看不懂啊,能不能求一個(gè)只有幾種貨幣互相轉(zhuǎn)換的,不要利息部分的,簡單一點(diǎn)就好,學(xué)習(xí)學(xué)習(xí)就好,可以嗎?
回復(fù)

使用道具 舉報(bào)

本版積分規(guī)則

手機(jī)版|小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術(shù)交流QQ群281945664

Powered by 單片機(jī)教程網(wǎng)

快速回復(fù) 返回頂部 返回列表
主站蜘蛛池模板: 欧美成人二区 | 一区中文字幕 | 国产成人在线视频 | 久久久成人一区二区免费影院 | 国产欧美日韩综合精品一 | 一级高清 | 99re视频在线 | 日韩欧美在线观看 | 亚洲激情在线 | 欧美黄色网 | 欧美黄视频| 日韩精品在线网站 | 中文字幕视频在线 | 日韩成人在线观看 | www.日韩 | 欧美精品一区二区三区在线播放 | 精品国产免费人成在线观看 | 色综合色综合色综合 | 伊人伊成久久人综合网站 | 国产精品福利久久久 | 成人激情免费视频 | 色视频网站免费 | 亚洲精品乱码久久久久久久久久 | 色吊丝在线 | 日本欧美国产 | 午夜精品视频一区 | 国产精品精品久久久久久 | 91一区二区 | 蜜桃毛片 | 久久丝袜视频 | 国产一区二区自拍 | 看黄在线 | 一级黄色播放 | 一区二区三区成人 | 干干干日日日 | 一区二区高清 | 激情av在线| 在线观看黄色电影 | 国产亚洲精品美女久久久久久久久久 | 亚洲一区久久 | 免费在线观看av的网站 |