How to develop an application in Scilab 2018-02-20 to develop... · 2019-01-11 · 1 HOW TO DEVELOP...
Transcript of How to develop an application in Scilab 2018-02-20 to develop... · 2019-01-11 · 1 HOW TO DEVELOP...
![Page 1: How to develop an application in Scilab 2018-02-20 to develop... · 2019-01-11 · 1 HOW TO DEVELOP AN APPLICATION IN SCILAB | Tutorial How to develop an application in Scilab 2018-02-20](https://reader034.fdocuments.in/reader034/viewer/2022042103/5e80eefc2956860b8f662926/html5/thumbnails/1.jpg)
1 HOWTODEVELOPANAPPLICATIONINSCILAB|Tutorial
HowtodevelopanapplicationinScilab2018-02-20ByYannDebray–ESIGroup
ThisworkislicensedunderaCreativeCommonsAttribution-ShareAlike3.0UnportedLicense.
![Page 2: How to develop an application in Scilab 2018-02-20 to develop... · 2019-01-11 · 1 HOW TO DEVELOP AN APPLICATION IN SCILAB | Tutorial How to develop an application in Scilab 2018-02-20](https://reader034.fdocuments.in/reader034/viewer/2022042103/5e80eefc2956860b8f662926/html5/thumbnails/2.jpg)
2 HOWTODEVELOPANAPPLICATIONINSCILAB|Tutorial
WelcometoScilab!Hereisafirstviewofyourdevelopmentenvironment.
FilebrowserOntheleftsideofthescreen,youwillfindthefilebrower.First,enterinthefolder/dev
![Page 3: How to develop an application in Scilab 2018-02-20 to develop... · 2019-01-11 · 1 HOW TO DEVELOP AN APPLICATION IN SCILAB | Tutorial How to develop an application in Scilab 2018-02-20](https://reader034.fdocuments.in/reader034/viewer/2022042103/5e80eefc2956860b8f662926/html5/thumbnails/3.jpg)
3 HOWTODEVELOPANAPPLICATIONINSCILAB|Tutorial
Openthescriptregr.scebydoubleclickingonit:
Scinotes–integratededitorOpenthescriptinScinotes
![Page 4: How to develop an application in Scilab 2018-02-20 to develop... · 2019-01-11 · 1 HOW TO DEVELOP AN APPLICATION IN SCILAB | Tutorial How to develop an application in Scilab 2018-02-20](https://reader034.fdocuments.in/reader034/viewer/2022042103/5e80eefc2956860b8f662926/html5/thumbnails/4.jpg)
4 HOWTODEVELOPANAPPLICATIONINSCILAB|Tutorial
YoucanattachtheScinoteswindowtoyourdefaultScilabenvironmentbydraganddropingtheblackribbononthetopofthewindow:
Thisisthescriptregr.sce:[FileName,PathName,FilterIndex] = uigetfile("*.csv"); if FilterIndex == 0 then messagebox("No file selected", "Error", "error", "modal"); return end A = csvRead(fullfile(PathName, FileName)); function regr(A) scf(); pressure = A(:,12); //Extract pressure component of the matrice A t = 1:length(pressure); [a,b] = reglin(t,pressure');//Linear regression on the pressure plot(pressure); plot(a*t+b,"r"); endfunction regr(A) Byclickingtheplaybutton,yourunthescriptregr.sce(youcanalsodothatwithoutopeningthefileinscinotes,byrightclickingthefileinthefilemanager).
![Page 5: How to develop an application in Scilab 2018-02-20 to develop... · 2019-01-11 · 1 HOW TO DEVELOP AN APPLICATION IN SCILAB | Tutorial How to develop an application in Scilab 2018-02-20](https://reader034.fdocuments.in/reader034/viewer/2022042103/5e80eefc2956860b8f662926/html5/thumbnails/5.jpg)
5 HOWTODEVELOPANAPPLICATIONINSCILAB|Tutorial
Importdata
ThefirstlineopensawindowswiththefunctionuigetfileByselectingthecsvfilesensor-data.csv,itreturnsthecompletepathofthatfile:PathName = /Users/yanndebray/Google Drive/Scilab Knowledge Base/Demos/wea ther_desktop_app/dev ItcanthenbegivenasinputtothefunctioncsvRead,thatreadscommasperatedvaluesinScilabA = csvRead(fullfile(PathName, FileName));
Variablebrowser&editorItcreatesavariableAinourvariablebrowser:
![Page 6: How to develop an application in Scilab 2018-02-20 to develop... · 2019-01-11 · 1 HOW TO DEVELOP AN APPLICATION IN SCILAB | Tutorial How to develop an application in Scilab 2018-02-20](https://reader034.fdocuments.in/reader034/viewer/2022042103/5e80eefc2956860b8f662926/html5/thumbnails/6.jpg)
6 HOWTODEVELOPANAPPLICATIONINSCILAB|Tutorial
Double-clickingonthevariableAwillopenitinaspreadsheetviewcalledthevariableeditor:
Byselectingthe12thcolumnofourmatrixA,wearedoingthesameaswritingintheconsole-->A(:,12)Wecanplottheresultwiththeiconinthemenu,orbytypinginyourconsole:-->plot2d(A(:,12))
![Page 7: How to develop an application in Scilab 2018-02-20 to develop... · 2019-01-11 · 1 HOW TO DEVELOP AN APPLICATION IN SCILAB | Tutorial How to develop an application in Scilab 2018-02-20](https://reader034.fdocuments.in/reader034/viewer/2022042103/5e80eefc2956860b8f662926/html5/thumbnails/7.jpg)
7 HOWTODEVELOPANAPPLICATIONINSCILAB|Tutorial
WritingfunctionsThefollowingfunctiontakesasinputamatriceA,selectthe12thcolumn,computesthelinearregressiononthedataandplotit:function regr(A) scf(); pressure = A(:,12); //Extract pressure component of the matrice A t = 1:length(pressure); [a,b] = reglin(t,pressure');//Linear regression on the pressure plot(pressure); plot(a*t+b,"r"); endfunction Oncedefine,youcancallthefunctionasfollowed:regr(A) Itwillreturnthefollowinggraph:
![Page 8: How to develop an application in Scilab 2018-02-20 to develop... · 2019-01-11 · 1 HOW TO DEVELOP AN APPLICATION IN SCILAB | Tutorial How to develop an application in Scilab 2018-02-20](https://reader034.fdocuments.in/reader034/viewer/2022042103/5e80eefc2956860b8f662926/html5/thumbnails/8.jpg)
8 HOWTODEVELOPANAPPLICATIONINSCILAB|Tutorial
DevelopaGraphicalUserInterfaceOpenthescriptinterface.sce:f = createWindow(); f.axes_size = [230 180]; f.figure_name = "My Interface"; uicontrol(f, ... "style", "pushbutton", ... "string", "Call my script", ... "position", [50 75 130 40], ... "callback", "regr"); Thisproducesthefollowingwindow:
![Page 9: How to develop an application in Scilab 2018-02-20 to develop... · 2019-01-11 · 1 HOW TO DEVELOP AN APPLICATION IN SCILAB | Tutorial How to develop an application in Scilab 2018-02-20](https://reader034.fdocuments.in/reader034/viewer/2022042103/5e80eefc2956860b8f662926/html5/thumbnails/9.jpg)
9 HOWTODEVELOPANAPPLICATIONINSCILAB|Tutorial
Byclickingonthebutton“CallmyScript”,itcallsthefunctionregrdefinedearlier,andproducesonceagaintheplotofthelinearregressiononthepressuredata.(pleasenotethatyouwillneedtoexecutethescriptregr.scebefore,otherwise,thefunctionregrwillnotbefoundandwillreturnanerrorinyourconsole).InScilab,thedevelopmentofgraphicaluserinterfacescanbeentirelyperformedwithonemainfunction,uicontrol:h = uicontrol(PropertyName,PropertyValue,...)
Inthenexttutorial,wewillteachyouhowtodevelopthefollowingapplicationforweatherforecast:
ReadmoreonhowtodevelopGUIswithScilab:http://scilab.io/how-to-develop-a-graphical-user-interface-tutorial/
ThisworkislicensedunderaCreativeCommonsAttribution-ShareAlike3.0UnportedLicense.