91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 72KB
    文件類型: .rar
    金幣: 2
    下載: 0 次
    發布日期: 2021-05-28
  • 語言: Matlab
  • 標簽: matlab??

資源簡介

原創畢業設計完工貼出來和大家分享一下吧-metro_simulation.rar
我的畢業設計是做一個地鐵列車運行過程的仿真系統。當然,不是很復雜。在simulink里面建立模型,然后用GUI對其中變量進行賦值,并通過GUI中的一段函數對制動點進行試湊,最后顯示出列車的速度-路程曲線,行駛總路程和時間。
-------------------------------------------
現將GUI中所調用的功能及其實現方法整理如下:
1、點擊按鈕,切換GUI。這個現實起來很簡單,只要在按扭的callback函數里寫上run; close;即可。

2、把GUI中edit框中的數值賦給simulink中對應的變量。這個問題一開始困擾了我好一段時間,看了很多例子都不行,有人說用set_param,但我用了之后總是會報錯說變量沒有定義。其實,只需要用等號對變量名進行賦值即可。例如:simulink中某個變量為M,edit框的確Tag為name,那么相應的代碼就是M=str2double);這里的str2double是將字符串轉變為double型的雙精度數。調用simulink前寫上options = simset;再進行調用sim;

3、從excel中讀取數據,并將其賦給對應的edit框。這個在math大哥的視頻里已經有詳細解析了,這里就不綴述了。

4、將GUI中的參數保存進excel文件中,這個與讀取過程類似,不過用的函數是uiputfile和xlswrite,具體的到matlab幫助里看一下就可以了,里面寫得非常清楚。

5、將最后的仿真結果繪制出來。這個實現起來相對比較麻煩。首先在simulink里要添加"to workspace"模塊(注意save format一定要選擇Array)。然后在調用simulink仿真的語句后面,用assignin函數將"to workspace"輸出的數據保存在workspace中的向量中,例如assignin; result是輸出的結果,k1是保存的向量名。在調用k1進行畫圖的時候,需要用evalin函數將k1從工作空間中讀取出來,如k2=evalin。

如果輸出的結果是最終的一個數,而非一個數組,則可以用result來獲取,這里的t是仿真時間長度,step為仿真步長。
----------------------
我用到的GUI主要部分就是這些,希望能對大家有些幫助。GUI入手的確比較困難,但只要多看幾個例子,問題就會迎仞而解。ilovematlab論壇的確給我們提供了一個良好的平臺,從這里學到了很多有用的東西。

----------------------------------
----------------------------------
附件中是我的源程序,運行時先從preface開始。
1.jpg
2.jpg
3.jpg
4.jpg

資源截圖

代碼片段和文件信息

function?varargout?=?graph(varargin)
%?GRAPH?M-file?for?graph.fig
%??????GRAPH?by?itself?creates?a?new?GRAPH?or?raises?the?existing
%??????singleton*.
%
%??????H?=?GRAPH?returns?the?handle?to?a?new?GRAPH?or?the?handle?to
%??????the?existing?singleton*.
%
%??????GRAPH(‘CALLBACK‘hobjecteventDatahandles...)?calls?the?local
%??????function?named?CALLBACK?in?GRAPH.M?with?the?given?input?arguments.
%
%??????GRAPH(‘Property‘‘Value‘...)?creates?a?new?GRAPH?or?raises?the
%??????existing?singleton*.??Starting?from?the?left?property?value?pairs?are
%??????applied?to?the?GUI?before?graph_OpeningFunction?gets?called.??An
%??????unrecognized?property?name?or?invalid?value?makes?property?application
%??????stop.??All?inputs?are?passed?to?graph_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

%?Copyright?2002-2003?The?MathWorks?Inc.

%?Edit?the?above?text?to?modify?the?response?to?help?graph

%?Last?Modified?by?GUIDE?v2.5?25-Mar-2002?12:19:15

%?Begin?initialization?code?-?DO?NOT?EDIT
gui_Singleton?=?1;
gui_State?=?struct(‘gui_Name‘???????mfilename?...
???????????????????‘gui_Singleton‘??gui_Singleton?...
???????????????????‘gui_OpeningFcn‘?@graph_OpeningFcn?...
???????????????????‘gui_OutputFcn‘??@graph_OutputFcn?...
???????????????????‘gui_LayoutFcn‘??[]??...
???????????????????‘gui_Callback‘???[]);
if?nargin?&&?ischar(varargin{1})
????gui_State.gui_Callback?=?str2func(varargin{1});
end

if?nargout
????[varargout{1:nargout}]?=?gui_mainfcn(gui_State?varargin{:});
else
????gui_mainfcn(gui_State?varargin{:});
end
%?End?initialization?code?-?DO?NOT?EDIT


%?---?Executes?just?before?graph?is?made?visible.
function?graph_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?graph?(see?VARARGIN)

%?Choose?default?command?line?output?for?graph
handles.output?=?hobject;
axes(handles.axes3);
distance=evalin(‘base‘‘k1‘);
velocity=evalin(‘base‘‘k2‘);
plot(distancevelocity);
xlabel(‘Distance?(m)‘);
ylabel(‘Velocity?(km/h)‘);
title(‘Figure?of?Velocity?against?Distance‘);
grid?on;
axes(handles.axes4);
t=evalin(‘base‘‘k3‘);
plot(tvelocity);
xlabel(‘Time?(s)‘);
ylabel(‘Velocity?(km/h)‘);
title(‘Figure?of?Velocity?against?Time‘);
grid?on;

%?Update?handles?structure
guidata(hobject?handles);

%?UIWAIT?makes?graph?wait?for?user?response?(see?UIRESUME)
%?uiwait(handles.figure1);


%?---?Outputs?from?this?function?are?returned?to?the?command?line.
function?varargout?=?graph_OutputFcn(hobject?eventdata?handles)?
%?varargout??cell?array?for?returning?output?args?(see?VARARGOUT);
%?hobject????hand

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----

?????文件??????13824??2009-05-16?12:32??metro_simulation(Final)\ABC.xls

?????文件??????13824??2009-05-14?19:25??metro_simulation(Final)\file2.xls

?????文件??????36163??2009-05-16?19:27??metro_simulation(Final)\graph.fig

?????文件???????3240??2009-05-15?22:48??metro_simulation(Final)\graph.m

?????文件??????10142??2009-05-16?14:13??metro_simulation(Final)\main.fig

?????文件??????33033??2009-05-16?16:04??metro_simulation(Final)\main.m

?????文件?????127680??2009-05-16?19:35??metro_simulation(Final)\metro_simulation.mdl

?????文件??????14336??2009-05-14?18:52??metro_simulation(Final)\parameter.xls

?????文件???????2205??2009-05-18?12:38??metro_simulation(Final)\preface.fig

?????文件???????3207??2009-05-11?10:35??metro_simulation(Final)\preface.m

?????目錄??????????0??2009-05-18?12:37??metro_simulation(Final)

-----------?---------??----------?-----??----

???????????????257654????????????????????11


評論

共有 條評論