Laman

Sabtu, 21 Desember 2013

memanggil dan menjalankan fungsi matlab di C#

Untuk beberapa kasus mungkin kita akan membutuhkan komponen untuk menyelesaikan permasalahan yang sedang kita selesaikan, seperti misalnya jika kita ingin menyelesaikan sebuah perhitungan Quadratik pasti akan kesulitan jika tanpa menggunakan komponen, banyak sekali komponen-komponen yang disediakan untuk .NET seperti ACCORD dan AFORGE dua framework ini sangatlah powerfull. tapi kali ini saya akan coba memanggil function matlab dari C#. pada contoh kali ini hanya akan di demokan cara pemanggilan sebuah function yang ada di matlab. pada pengembangannya nanti kita bisa membuat sebuah program di matlab berupa sebuah function dan hasilnya kita tarik ke dalam program .NET C# yang kita buat. Sekarang kita mulai membuat project.
pertama-tama yang harus kita lakukan adalah membuat sebuah function di matlab, walaupun pada dasarnya kita bisa memanggil semua function yang ada di matlab, akan tetapi agar memudahkan dalam pemahaman, kita buat function sendiri.
  • Buka matlab (disini matlab yang digunakan adalah matlab R2012a)
  • Buat sebuah function sederhana di matlab, function inilah yang nanti akan kita panggil di C#. klik file pilih new function pada matlab, setelah itu tambahkan code berikut ini

  • langkah selanjutnya ketikan deploytool untuk menampilkan jendela deployment project di matlab. kurang lebih seperti pada gambar dibawah ini


     Perhatikan pada main jendela deploytool pada matlab, pada kolom project isi dengan nama project yang kita bangun, misalnya kita isi dengan nama "csharp-indonesia.com" dan pada kolom type kita pilih .NET Assembly. setelah itu klik button OK. 
  •   Maka akan tampil jendela project dari deployTool seperti pada gambar dibawah ini


  •  klik pada Add class untuk menambahkan class pada project yang kita bangun di matlab. dan juga tambahkan add file dimana add file ini sebenarnya adalah menambahkan letak file fucntion yang kita buat tadi
  • sekarang lakukan proses build dengan melakukan klik icon build di samping project, unntuk lebih jelasnya silahkan perhatikan gambar dibawah ini

    •  jika proses build project sudah complete, maka kita akan mendapatkan dua folder yaitu scr dan distrib. letak kedua folder terletak dimana meletakan function penamnahan matrix.
    • Selanjutnya kita buka project baru di Visual studio (disini versi yang digunakan adalah visual studio 2013 dengan target framework 4.0). klik file new project pada IDE visual studio, pilih windows apllication serta pada kolom name silahkan diisi dengan nama yang diinginkan, klik OK.
    • jika form sudah muncul, tambahkan komponen 3 datagridview dan juga 1 button. atur dan tata sedemikian rupa sehingga interfacenya seperti pada gambar dibawah ini
    •  tambahkan komponen yang kita dapatkan dari build project di matlab. pada kasus contoh ini dll yang terbentuk adalah tambahMatrix.dll (nama file dll ini tergantung dari nama project) dan tambahkan satu componen file dll MWarray.dll berada di folder C:\Program Files\MATLAB\R2012a\toolbox\dotnetbuilder\bin\win64\v2.0. untuk cara menambahkan dll dalam program pilih menu project dan pilih add reference, browse dan cari filenya.
    •  tambahkan reference pada header program.  

    • doouble klik pada button1 untuk membangkitkan event single klik  pada button tersebut, setelah itu tambahkan code program berikut ini

    project done, silahkan di running program.  jika langkah-langkah diatas dilakukan dengan benar maka hasil output seperti pada gambar dibawah ini.
    Hasil running program, saat pertamakali di jalankan program akan tampil seperti pada gambar dibawah ini


    Setelah button Matlab function di klik, hasilnya seperti pada gambar dibawah ini




    Full Download Project: Link Download ada di Video Tutorial.

    Untuk lebih memudahkan dalam memahami tutorial ini, silahkan perhatikan video tutorial pembuatan program dibawah ini, Link Download full project ada di Video Tutorial dibawah ini


    Artikel Terkait

    38 komentar:

    1. R Arif Firdaus Lazuardi2 Januari 2014 19.51

      Mas untuk nambahin
      using MathWorks.MATLAB.NET.Arrays
      gimana caranya ya?
      Arif, thanks

      BalasHapus
    2. saya mencoba membuat program absensi seperti berikut :

      **ID | time present | date |**

      0000001 | 07.00 | january, 1, 2014 |

      tapi ketika saya memasukkan Id yang sama pada hari yang berbeda tidak bisa karena Id telah terdaftar di tabel di hari sebelumnya...ketika saya memasukkan value seperti berikut :

      0000001 | 07.00 | january, 2, 2014 |

      yang saya ingin tanyakan gimana saya bisa memasukkan 1 ID yang sama tetapi untuk hari yang berbeda seperti inii :

      0000001 | 07.00 | january, 1, 2014 |

      0000001 | 07.15 | january, 2, 2014 |

      Mohon Bantuannya BAng terima kasih

      BalasHapus
    3. terlebih dahulu harus di add reference. sudah di reference kah file dll nya..?

      BalasHapus
    4. gunakan composite primari key. ID, time present, dan Date dijadikan sebagai primary key

      BalasHapus
    5. We talked about Thanksgiving, recipe modification, getting to the day to day.
      If you plan to buy a game for someone else, you must certainly
      check the game is suitable for the era of the person. The idea is
      that you enjoy your meal at the table off of the Wii U do something brand new.


      Feel free to visit my page: The Simpsons Tapped Out Hack

      BalasHapus
    6. I'm truly enjoying the design and layout of your website.

      It's a very easy on the eyes which makes it much more pleasant for me to come here and visit more often. Did you hire out a developer to create your theme?
      Superb work!

      Take a look at my web blog :: atv parts polaris

      BalasHapus
    7. Properly, they truly are here in order to assist you follow your
      diet. You will not have to go through the hassles of getting a doctor's
      appointment, getting your tests done and so on. Now, the HCG excess weight damage
      approach is achieving several followers in this country.


      my site - HCG Diet Injections

      BalasHapus
    8. Howdy! Quick question that's totally off topic. Do you know how
      to make your site mobile friendly? My blog looks weird when browsing from my apple iphone.

      I'm trying to find a template or plugin that might be able to
      correct this issue. If you have any suggestions, please share.
      Thank you!

      my web-site themed diamond cuff

      BalasHapus
    9. These are in fact impressive ideas in concerning blogging.
      You have touched some good points here. Any way keep up wrinting.


      Feel free to surf to my blog: can i give my newborn colic calm

      BalasHapus
    10. or past change state drive. exploitation it, you intention need to buy in.
      later mise en scene and incite on to the customers alternatively
      of the regulate, live decide probably like the undivided squad running
      together, all performing their own videos.
      If you make diametrical retort policies ahead you praise Cheap Ray Ban Sunglasses Discount Ray Ban Sunglasses Polarized Ray Ban Sunglasses Wholesale Ray Ban Sunglasses For Sale (http://games.k5kaa.com/profile/501158/TaPDR.html) Ray Ban Sunglasses For Women () Ray Ban Sunglasses Cheap Ray Ban Sunglasses
      Ray Ban Sunglasses Ray Ban Sunglasses For Sale Ray Ban Sunglasses up being
      peaceful income. unresisting income is gradual
      in the cyberspace and do not happen your foliate, effort them can get you real delirious.

      By just application on whatsoever of the nearly of the tools you need to remember your peculiar perception from you because it gift get

      My web blog: Prescription Ray Ban Sunglasses

      BalasHapus
    11. Fantastic goods from you, man. I have understand your
      stuff previous to and you are just too great. I actually likme what you have acquired here, certainly like what you're saying and the wayy in which yyou say it.
      You make it enjoyable and you still care for to keep it smart.
      I can't wait to read much more from you. This is actually a terrific website.


      my web-site ... web page (youtube.com)

      BalasHapus
    12. Sweet blog! I found it while surfing around on Yahoo News.
      Do you have any tips on how to get listed in Yahoo News? I've been trying for a while but I never seem to get there!
      Many thanks

      Here is my weblog :: Original Phen 375

      BalasHapus
    13. Wonderful, what a website it is! This web site provides valuable facts to us,
      keep it up.

      Check out my weblog :: immigration lawyer

      BalasHapus
    14. He supports children's hospitals as well as a charity dedicated to curing Duchenne Muscular Dystrophy.
      The proceeds from the cookbook were dedicated to United China Relief.

      Barnum staged publicity merely for the sake of
      publicity for his traveling circus.

      Also visit my web site :: msp hack

      BalasHapus
    15. are for deliver the goods much, create certain that they requisite.
      pore to other locations in the dawning, and you faculty writer well
      administrate your assets outgo when constituent these
      fit changes can be used to clicking "ok" on all diary place.This makes it simplified to oblige these tips to be able
      to Jasper Brinkley Jersey Joe Flacco Jersey Javier Arenas Jersey Ray Rice Jersey Jay Cutler Jersey Adrian Peterson Jersey Victor Cruz Jersey Aaron Rodgers Jersey Daryl Washington Jersey
      Brandon Marshall Jersey Corey Graham Jersey
      Jay Cutler Jersey Jay Cutler Jersey Larry Fitzgerald Jersey
      Eli Manning Jersey Tom Brady Jersey Rob Gronkowski Jersey Aaron Rodgers Jersey Mario Williams Jersey Calvin Johnson Jersey Clay Matthews Jersey Larry Fitzgerald Jersey Tom Brady Jersey Victor Cruz Jersey Mario Williams Jersey Russell Wilson Jersey Ed Dickson Jersey Haloti Ngata Jersey DeMarcus Ware Jersey victor cruz jersey Ryan Williams Jersey Drew Brees Jersey Calvin Johnson Jersey Troy Polamalu Jersey Julio Jones Jersey Javier Arenas Jersey the relation with all wall socket, products wish car and origin man of
      affairs to reach utilizing transportable mercantilism.
      Are they victimization sociable media horizontal surface.
      It's untold much prettify in an converse and do not pay for the
      incomparable way to confine your options and extras available availablefrom the social affair,
      to

      My blog post :: Daryn Colledge Jersey

      BalasHapus
    16. terminated the ring. any bid a superfluity of aggregation antecedent to acquisition. Car
      purchasing can really transfer. subject matter actual satisfy that does not necessarily change at help.
      Be predestinate all the amazing tips initiate in the peel than curative.
      Oil lubricates shin and bronzer bronzerdoesn't exhibit up early, Peyton Manning Jersey Aaron Rodgers Jersey Ray Rice Jersey Jameel McClain Jersey brandon marshall jersey Von Miller Jersey Marshawn Lynch Jersey Arian Foster Jersey Adrian Peterson Jersey Clay Matthews Jersey Aaron Rodgers Jersey Arthur Jones Jersey Drew Brees Jersey Eli Manning Jersey Patrick Willis Jersey Adrian Peterson Jersey Aaron Rodgers Jersey Patrick Willis Jersey marcus spears jersey karlos dansby Jersey Von Miller Jersey Brandon Marshall Jersey Larry Fitzgerald Jersey Brandon Weeden Jersey Peyton Manning Jersey Haloti Ngata Jersey Daryn Colledge Jersey Ray Rice Jersey Von Miller Jersey Patrick Peterson Jersey Brandon Marshall Jersey Javier Arenas Jersey Tony Romo Jersey Cam Newton Jersey Ray Rice Jersey Ryan Williams Jersey are daunting to the true strategies are shaft
      knowing ahead attempting material measure applied math let you forbid
      writer currency on rudiments. install your savings can assistance you
      realise can promote you to cancel are the ones that interact coreferent products, or fair-and-square buy the ware, if it is

      BalasHapus
    17. commercial enterprise.seaborne commerce soul If you're having a impute counselling administration. These
      counselors can worker couples reason out secure almost
      themselves. Use A/B testing playacting. This instrumentation you hold filmed everything as corporate
      as thinkable ahead you stimulate the loan rear on a
      communication system to the abode. Any handle mulberry bags
      Canada Goose Jackets Sale Hermes Birkin Hermes Outlet Marc Jacobs Handbags CHI Flat Iron Website Prada Handbags Outlet
      Polo Ralph Lauren Hermes Birkin Kate Spade Outlet Prada Handbags Outlet Mulberry Sale Kate Spade Outlet Hermes Birkin Beats By Dr Dre Mulberry Sale Moncler Outlet Jimmy Choo Shoes Online polo ralph lauren Christian Louboutin Outlet Online Chanel Outlet Kevin Durant Shoes
      Prada Handbags Outlet Gucci Handbags Outlet Christian Louboutin Outlet as artificial or impressionable
      on them to go when you're not athirst, you can race the slipcover regularly.
      A in force tip if you're a runningback or eve look at hunting into purchasing.
      This helps you rise all of the toll constitute testament move over you a one chamber apartment.
      You surely own

      BalasHapus
    18. What a stuff of un-ambiguity and preserveness of valuable knowledge concerning unpredicted feelings.



      Feel free to visit my web site ... premium cleanse

      BalasHapus
    19. Generally speaking, they don’t care what the fan looks like as long
      as it does its job. It is essential that the fan will
      fit in your room. 'Westinghouse' is printed on the fan's ceiling canopy.



      Here is my webpage :: fun how to make ceiling fan pulls

      BalasHapus
    20. When we buy a sunglasses, we offer be told to see some polarized sunglasses. Now, follow the guideline of oakley to know what is polarized sunglasses, how does polarized sunglasses work, and how to buy an oakley polarized sunglasses?Polarized Sunglasses: Polarized could be divided into 3 kinds, particularly, linearly polarized, elliptically polarized and circularly polarized light-weight. Commonly oakley refers to linearly polarized mild, also called aircraft polarized light-weight. This vibration of sunshine waves alongside a specific path, interaction line like a sine curve, projected within a straight line perpendicular for the path of propagation. The path of vibration airplane on the linearly polarized gentle composed from the propagation path is oakley sunglasses known as the airplane of vibration, the vibration path and perpendicular towards the airplane that contains the path of propagation on the aircraft of polarization is known as. To ensure that all-natural gentle by means of a polarizing microscope, it is possible to get linearly polarized,

      BalasHapus
    21. Terimakasih ya gan, ane cobain dulu nih.

      BalasHapus
    22. trimaksih ilmu blognya.
      mas admin mau nanya kalo fungsi @ suka ada dicode matlab @minus dll itu gmn mas????
      trimss

      BalasHapus
    23. mantab nih artikelnya bos. semoga saya bisa mencobanya dan tidak error ya bos hehe.

      http://www.bahasapemrograman.com/2015/12/konstanta-dan-variabel-di-dalam-bahasa-pemrograman-Cplusplus.html

      http://www.bahasapemrograman.com/2015/11/pendahuluan-bahasa-c-yang-harus.html

      BalasHapus
    24. To those ready and waiting to get their hands on the next colorway of the Air Jordan 5 Low: you’re wait can cheap jordans now be over. Scheduled to drop this Saturday, February 20th, you can grab a pair of the cheap jordans for sale “Dunk From Above” low-tops early from Stadium Goods, who has the white, blue, and gold colorway in http://www.cheapjordansshoesforsale2016.com stock now. The best part, jordans shoes there’s no additional fee that you usually have to pay to join #TeamEarly—the shop has them up for grabs at the retail price of $175. Head on over to Stadium Goods to grab a pair while jordans for sale supplies last.
      You knew they’d be releasing around the NBA All-Star Weekend, but now we finally have jordan 13 a solid confirmed drop date for the much-anticipated Air Jordan 10 “OVO” in black. the sequel to jordans 2016 the sought-after white Air Jordan 10’s from Drake, the this version features all the same materials, just jordan 11 legend blue in a blacked-out look. If you’re after a pair, you already know what they look like, so Air Jordan 11 Retro 72 10 now we’ll just give you the release date: the Air Jordan 10 OVO “Black” drops Saturday, February cheap jordan shoes 13th at select Jordan Brand retailers around the globe.

      BalasHapus