ECG Digitization in MATLAB
Buy This Project
Hello friends, I hope you all are doing great. In today's tutorial, I am going to show you How to do
ECG Digitization in MATLAB. If you are new to ECG signals then you should have a look at
Introduction to ECG. I have also posted many different simulations on ECG in which I have extracted different features of ECG signals but in today's tutorial, we are gonna extract the ECG signal itself from its image. I have also saved this ECG signal in a txt file so that you can use it. This code is not open source and you can buy it from our shop by clicking the above button.
I have designed a GUI in MATLAB and it will take image of ECG signal as an input and then will give the digital form of that ECG signal as an output. There are few restrictions on this code and its not necessary that it will work on all images of ECG signal, but I am sure it will work on most of them. I have also added three images in the folder which works great with this code. You should also have a look at
ECG Simulation using MATLAB and
ECG Averaging in MATLAB. So, let's get started with ECG Digitization in MATLAB:
ECG Digitization in MATLAB
- When you will buy this MATLAB code, you will get an rar file.
- Extract this rar file and it will contain below files in it:
- You need to run Main.m file which is a MATLAB file.
- Open this file in MATLAB and run it.
- If everything goes fine then it will open up as shown in below figure:
- Click this button which says Load Image File.
- When you click this button, it will open up a dialog box as shown in below figure:
- Here you need to select the image of ECG signal, which you want to digitize.
- So, I am selecting ECG1.png and the results are shown in below figure:
- The first axes is showing the ECG Image file as it is.
- I have converted this ECG Image File into Gray Scale which is shown in axes 2.
- Further, I have converted this Dray Scale Image into Binary Image which is shown in axes 3.
- If you have noticed we have a blue line in ECG Binary Image.
- I have added this line and taken it as an x-axis, the algo is reading the values of black pixels and then subtracting it from this x axis line.
- In this way, I am getting my complete ECG Signal and the Axes 4, which is named as ECG Signal, is displaying this digital ECG Signal.
- I have converted pixels into mV, which you can change by yourself in the code.
So, that was all about ECG Digitization in MATLAB. If you got into any trouble regarding this project then you can ask in comments and I will try my best to resolve them. Thanks for reading !!! :)
How to Upload Files using FTP in LabView
Hello friends, I hope you all are doing great. In today's tutorial, I am gonna show you
How to upload Files using FTP in LabView. It's gonna be a quick tutorial as there's not much to do :) but you have to read and follow it carefully because if you made even a small mistake then it won't work.
FTP is an abbreviation of File Transfer Protocol and using FTP we can easily upload or download files from our web server. We can use different FTP clients like FileZilla in order to do it manually but today we are gonna have a look at How to upload files automatically using FTP in
LabView. So, let's get started with FTP in LabView:
How to Upload Files using FTP in LabView
- When you are working on some Embedded project where you need to upload your sensor's data on some web server then you need to use FTP.
- For example, if you are working on Home Automation or some security project and you want to display the values of your sensors on some online website, then in such situations you can easily use FTP and can upload your sensor's data.
- There are many different ways to use FTP but if you are using LabView then here's how you are gonna upload it.
- First of all, what you need to do is, you need to save your sensor's data in a txt or csv file.
- After that simply Log in your FTP account and upload that file on your server.
- Here's the screenshot of my LabView code which is uploading the data.txt file on my website using FTP.
- In the first TextBox, you need to give the Password of your FTP account.
- In the second TextBox, you need to give the Username of your FTP account.
- In the third TextBox, you need to give the IP Address of your website, don't use the name of your site it doesn't work in LabView. You have to find the IP Address of your site which you can easily find using some online tool and place it in this TextBox.
- In the fourth TextBox, you need to give the File Location, where you want to save your file on the server.
- In the fifth TextBox, you need to give the File Location on your Laptop.
- I have used FTP put File fuction of LabView and when you press the button Boolean, then it will automatically Log in to your FTP account and will upload the file.
- It will hardly take 1 sec for the whole process.
- You can download this LabView code by clicking the below button and don't forget to change all these values otherwise it won't work. :)
Download LabView Simulation
- Once the file is uploaded on your server, you can then use PHP to extract and display it on some web page.
So, that was all today. I hope now you can easily upload your files via FTP in LabView. If you still got into some trouble then ask in comments and I will try my best to resolve them. Will meet you guys in the next tutorial. Till then take care and have fun !!! :)
ECG Averaging in MATLAB
Buy This Project
Hello friends, I hope you are doing great. Today, I am going to share an expert level project which is ECG Averaging in MATLAB. If you are new to ECG then you should have a look at
Introduction to ECG. I have already shared
ECG Simulation using MATLAB in which we have seen how to simulate an ECG signal and then diagnose heart disease. We have also extracted ECG features in that project. So, if you guys haven't read that tutorial then I would suggest you to not read this one. First read
ECG Simulation using MATLAB and then you should read this tutorial. Today's project is quite an extension of our previous project ECG Simulation using MATLAB. Our team has designed this project after quite a lot of effort that's why its not free to use but you can easily buy it from our shop using PayPal, by clicking the above button.
In today's tutorial, we are gonna have a look at How to do ECG Averaging in MATLAB. ECG Signals normally have a lot of noise in them that's why its quite necessary sometimes to average the ECG signal so that we get better results. That's where ECG averaging is required. So, lets get started with ECG Averaging in MATLAB.
ECG Averaging in MATLAB
- Let me first explain in detail why we need to average an ECG signal and how we are gonna do that.
- Check ECG signal shown in below figure:
- In the above ECG signal, we can see there's a lot of noise in ECG waveform, which may affect our results so there's a need to apply some filters to smoothen out the ECG waveform.
- Another way of removing noise is ECG averaging.
- In ECG averaging technique, we cut signle ECG signal and then we extract all of our peaks.
- Finally we add them up and create an average waveform.
- I have shown this whole procedure in below figure:
- In the above figure, you pretty much got the idea behind this project.
- Now here's its MATLAB GUI, shown in below figure:
- It has two Containers at top and a full length Graph at the bottom.
- Now, when you Click the Button the it will ask for the ECG data file, as shown in below figure.
- Currently this project has eight data files with it and I have tested all of them and they are working quite fine.
- I have downloaded all the data files from Phsio Bank website. You can read its more details in ECG Simulation using MATLAB.
- Now when you will upload the files then it will take all the peaks and then will add them up one by one and will give you final output in the right container.
- The whole procedure for data1 is shown in below figure:
- I hope now you got the complete idea of its working but still if you have any questions then you can ask in comments and I will help you out.
- Here's the final look of this project:
- I have also created this video in which I have explained it in more detail and shown how it works.
- So, if you wanna buy this Project then I would suggest you to must watch this video before so that you got the complete idea of what you are buying.
- Here's the video for ECG Averaging in MATLAB:
So, that's all for today. I hope you have enjoyed today's tutorial. Will see you guys in next tutorial. Till then take care and have fun !!! :)
Servo Motor Control using myRIO
Hello everyone! I hope you all will be absolutely fine and having fun. Today, I would like to provide a complete discussion on
Servo Motor Control using myRIO. In this tutorial I will tell you about the control of a servo motor using NI myRIO. First of all, I will give you a brief introduction on servo motors and then we will proceed towards their interfacing with myRIO. Servo motor is an electronic device with a small output shaft. This shaft can be adjusted at different angles for the different purposes. We can adjust this shaft by sending a signal usually known as servo coded signal. Servo motor is able maintain a particular angle as long as it has the servo coded signal at its input.
Servo motor changes the angular position of its shaft with every change in the servo coded signal applied at its input. I have already designed and shared
Servo Motor Control in Proteus. If you are using the servo motor for the first time then you must go through this tutorial. This design is always helpful to the beginners. In my previous tutorial I have controlled DC motor using NI myRIO. DC motor is a simple device having two input terminals. We just have to supply voltage at its terminals and it starts rotating in either direction depending upon the polarity of the applied voltage. Whereas, servo motor has three input terminals, two terminals are for the power supply and one is for sending servo coded signal to rotate at specific angle and in specific direction as well. If some electrical projects require some mobile (move able/not static) tasks, servo motor will be the better option. It is easily available in the market and has a low cost. There are a lot of real life applications associated with servo motors. For example, robotics, elevators, air crafts, remote controlled appliances, vehicles, solar tracking system, automated baby cradle system, conveyor belts system and a lot more. The further detail about servo motor control using myRIO will be given later in this tutorial.
Servo Motor Control using myRIO
Servo Motor is a device with a small output shaft. It has three input terminals. Two terminals are for the power supply and the third is for sending the servo coded signal. The electrical or electronics projects where there is a need of motion, servo will be the best option in this case. The shaft of the servo motor changes its position corresponding to the servo coded signal applied at its input. It has a wide range of applications including robotics, automated baby cradle, solar tracking systems, elevators etc. Servo motor is shown in the figure given below.
Note:
I have already shared different articles on control of a servo motor as given below.
1. Servo Motor Pins
- Servo motor has three pins, two for the power supply and one for sending servo coded signal.
- These three pins are listed in the table given in the figure shown below.
- Servo motor along with its pins is shown in the figure given below.
2. Servo Motor Pins Description
- We must know the function of each pin of any electronic device.
- Pin functions of all the pins are provided in the table shown in the figure given below.
3. Servo Motor Dimensions
- In the figure shown below, servo motor is divided into different segments e.g. A, B, C etc.
- The dimensions of each segments are provided in the table given in the figure shown below.
4. Servo Motor Specifications
- Specifications are such parameters on the basis of which a device can become more popular.
- Servo motor specifications are listed in the table given in the figure shown below.
5. Servo Motor Ratings
- The power requirement of any device can be estimated through its ratings.
- Servo motor ratings are given in the table shown in the figure below.
6. Servo Motor Applications
- Servo motor has a wide range of real life applications.
- Some of them are listed in the table given in the figure shown below.
7. Servo Motor Control using myRIO Wiring Diagram
- I have made a completely labelled wiring diagram for servo motor control using myRIO.
- A complete wiring diagram is given in the figure shown below.
8. Servo Motor Control using myRIO Actual Wiring Diagram
- The actual wiring diagram for servo motor control using myRIO is shown in the figure given below.
9. NI LabVIEW Complete Front Panel Window
- The complete front pane; window for servo motor control using myRIO is given in the figure shown below.
10. NI LabVIEW Complete Block Diagram Window
- The complete Virtual Instrument (VI) for servo motor control using myRIO is shown in the figure given below.
- You can download the wiring diagram for servo motor control using myRIO and the complete LabVIEW VI, just by clicking on the button below.
That is all from the tutorial
Servo Motor Control using myRIO. I have tried my level best to provide all the necessary detail about servo motor control using myRIO. I hope you have enjoyed the tutorial and will appreciate my efforts. If you found something missing, please let me know so that I can update this tutorial accordingly in order to avoid any future inconvenience. I will share different projects on myRIO in my upcoming tutorials. Till my next tutorial take care and bye bye :)
myRIO GPS Interfacing
Hello everyone! I hope you all will be absolutely fine and having fun. Today, I would like to provide a complete discussion on introduction to GPS and myRIO as well as
myRIO GPS Interfacing as the most related part. First of all I would like to tell you about GPS, from what it is abbreviated, at which principle it works and how it plays its role in our daily life. GPS is basically derived from the word Global Positioning System. GPS is a complete network of satellites which are continuously rotating in their orbits and send information to earth about their accurate position in space. GPS receivers are used to receive the signals, and the received signals help us to estimate the precise time, position and speed of anything moving around. I have share
GPS Library for Proteus in my previous tutorials, which is quite helpful for the engineering students.
GPS plays a vital role in our daily life. It provides a complete map, i.e. it helps us to easily go through the places which we have never seen before. GPS first system was developed by Americans in 1960's. They introduced it to locate their ships in the ocean. This system has five (5) satellites which are used to locate their ships once in every hour. GPS has three basics parts named as satellites, control stations and receivers. All of these will be explained later. This entire system is able to provide us the information about altitude, precise position, speed etc. But there are also some errors while estimating all these things. The major cause of its error is the inaccurate time of the receivers clock. Due to this fact, we get same GPS coordinates for the different points and it becomes impossible to locate anything accurately. For example, in a small garden we want to locate a robotic lawn mower. But due to the error problem we get the same GPS coordinates, for the initial as well as the final position of the lawn mower. This system has a lot of real life applications e.g. mapping forests, military applications, intelligence applications, locating ship, navigating vehicles and aircraft, guide hikers etc.The further detail about the GPS and myRIO GPS interfacing will be provided later in this section.
Introduction to GPS Receiver Module
GPS stands for Global Positioning System. It is the network of satellites which are orbiting in their orbits and send information to the earth, about the precise position. This system plays a vital role in daily life. It was first introduced by Americans to navigate their ships. It is now enhanced to a great level and is able to provide information about forest mapping, guide hikers, locating air crafts, navigating vehicles and a lot more. If we want to go at newer places which we have never visited before, we can easily go there taking help from the GPS system by using GPS receiver. The GPS receiver or a GPS module is shown in the figure given below.
- You can see from the above figure, I have cut white and yellow wire because I am not using it.
- I have used the other four remaining wires for the communication between GPS module and myRIO.
- I have also provided the detailed article on Getting Started with myRIO and Introduction to myRIO, you should also go through this articles.
1. GPS Pins
- GPS has total six (6) pins, but we will use only four (4) of them.
- Each of the pins has different functions to perform.
- GPS module/receiver pins are provided in the table shown in the figure given below.
2. GPS Pins Description
- Since each pin is assigned with a different task, so must know about functions associated with each pin.
- GPS pin description are listed in the table given in the figure shown below.
3. GPS Receiver Operating Conditions
- Like all other devices, GPS receiver also works on certain conditions, which must be fulfill to get better performance.
- Normal operating conditions for this particular GPS receiver are listed in the table given in the figure shown below.
4. GPS Receiver Specifications
- The specifications are such parameters which show the efficiency of that device.
- GPS receiver specifications are provided in the table shown in the figure given below.
5. GPS Receiver Ratings
- Ratings tell us about the power, current and voltage requirement of any electronic device.
- GPS receiver absolute maximum ratings are listed in the table shown in the figure given below.
6. GPS Receiver Applications
- Most of the electronic devices are known on the basis of their applications.
- GPS receiver applications are listed in the table given in the figure shown below.
myRIO GPS Interfacing
In the previous section we have discussed i detail about the basics parameters of the GP receiver module and the different properties and applications associated with that particular module. Now, in this section of the tutorial myRIO GPS interfacing, I am going to tell the step by step procedure to be followed in order to interface a GPS receiver module with NI myRIO. So, the major focus of the section will be the only discussion on the interfacing of GPS receiver module using NI myRIO and NI LabVIEW. All the step are explained in detail below. So, do follow all the steps in the same way as I did.
1. myRIO GPS Interfacing Actual Wiring Diagram
- In my previous tutorial, I have shared the detail about Interfacing of GPS Module with Arduino in Proteus ISIS, you must have a look at this article for the better understanding of the current article.
- GPS receiver module interfaced with myRIO is given in the figure shown below.
2. NI LabVIEW Final VI for sReceiving GPS Data
- The Virtual Instrument (VI) is huge in size, so I have added it into three different parts.
- Each part of the entire VI is given in the separate figure.
- Below, I am going to share each part of the VI and will explain a bit about it later.
- The first part of the VI for receiving GPS data is given in the figure shown below.
- In the first part of the VI as shown above, I have used VISA Serial Port for the communication between GPS receiver and myRIO.
- VISA Resource Name is basically the MXP of myRIO as described in Introduction to myRIO.
- ASRL1 shows the GPS receiver is attached with the MXP A of myRIO.
- If you want to attach your GPS receiver with MXP B, then you have to select ASRL2.
- 9600 is the baud rate, shows the rate at which GPS is communicating with myRIO or vice versa.
- So, that was the discussion about the first part of VI for getting GPS data.
- The second part of the VI is given in the figure shown below.
- At the extreme left of the above figure, I have used a VISA Read block, which is reading continuously 100 characters when termination character encountered.
- Then I used a block Concatenate String which takes input from VISA Read and produces NMEA sentences, which are back to its input as feedback.
- Moving to the right the next small While Loop is for extracting the data fields.
- The next comparatively large loop is for getting latitude, longitude, UC time, speed etc.
- And at the top right corner of the above figure I have added a delay of 100 milli seconds.
- So, that was the detailed description of the second part of the VI for getting GPS data usig NI myRIO.
- The 3rd part of the VI for getting GPS data is shown in the figure given below.
- In the above figure, inside the While Loop, I have used Digital Input whose output is connected to and LED.
- The above step describes the monitoring of one pulse per second signal (1PPS) on the on-board LED 3.
- Then I have used Merge Error block to produce a single final output.
- Then, I used a Simple Error block in order to visualize the error, if it occurs.
- At the end, I have used a Reset myIRO block, which resets the FPGA (Field Programmable Gate Array) target and all the input/output channels on myRIO.
- So, that was the detailed description of the third part of the block diagram window VI for receiving GPS data using NI myRIO.
- You can easily receive the data from GPS receiver by following all of the above steps carefully.
3. NI LabVIEW Final GUI for Receiving GPS Data
- I have made a complete VI in LabVIEW to receive GPS data.
- The arrangements of the blocks e.g.time, latitude, longitude and speed are made to provide a better look to the GUI.
- An LED on the right side shows the one pulse per second (1-PPS).
- On the bottom left of the above GUI, I have made a region to obtain all the data from the GPS receiver module.
- The final form of GUI (Graphical User Interface) is given in the figure shown in the figure below.
- In the above figure, at the bottom right you can see a button with a red colored small square inside it.
- Using this button, you can terminate your program when it is in running condition, this function can also be performed using Esc button from either your personal computer or from your laptop.
4. Received GPS Data
- The data obtained from the GPS receiver is displayed on the GUI.
- The GUI is given in the figure shown below.
- From the above figure, you can see that the longitude, longitude are properly obtained.
- At the top left corner of the above GUI, I have shown the exact time inside a Numeric Indicator.
- Date has also been displayed in the middle of the right side of the GUI.
- I have displayed longitude, latitude, time, date etc as shown in the figure above.
- So, that was the brief discussion on the results obtained from GPS receiver module.
- You can download the complete NI LabVIEW VI (Virtual Instrument) here by clicking on the button below.
That is all from the tutorial
myRIO GPS Interfacing. I have covered almost all the necessary details about getting GPS data from the satellites using GPS receiver/module. I have also provided the detail about the GPS network and working of the whole network. I hope you have enjoyed this tutorial and hoping for your appreciation for this effort. I have shared the complete NI LabVIEW VI (Virtual Instrument) for myRIO GPS interfacing. Just by downloading it you will be able to get GPS data using any of the GPS receiver/module. I will further share interesting and informative topics in my later tutorials so, till then take care and bye :)
MATLAB Image Processing
Hello everyone! I hope you all will be absolutely fine and having fun. Today, I am going combine all of my previously published tutorials based on
MATLAB Image Processing. Image processing can be defined as to convert an image into digital form and to perform some actions on it to improve its quality. I have published a number of tutorials on MATLAB image processing but they are not well arranged. So, I am going to combine the links for all of them in order to access them easily. All of the projects that I am going to combine today, are designed and compiled by our team with a lot of hard work.
A number of
MATLAB Image Processing based tutorials are compiled into this single tutorial. These are divided into two different categories i.e free and payable. Some of them are totally free and their source code are easily available to download. Some are not free but we have imposed a low cost on it and the students can easily purchase them even with their pocket money as well. Image processing is an amazing technique now a days and is difficult to do that is why we have imposed a bit cost on some of the major projects. The detailed description of each of the single project based on MATLAB image processing will be given later in this tutorial.
MATLAB Image Processing
Here in the tutorial
MATLAB Image Processing, the combined list of all the previously published tutorials will be given in detail along with their accessible links. First of all I would like to explain you a bit about image processing technique.
- To convert an image into the digitized form and perform some kind of actions on it specially to improve its quality is basically known as image processing technique.
- The images below display the conversion of an image into digitized form to improve their quality.
- The image on which I am going to perform some of the actions for its quality improvement is shown in the figure below.
- Now I am going to perform some of the major actions on it to improve its quality.
- The figure shown below displays the tasks performed on the above image.
- So that was a bit about image processing technique.
- Now, I am going to combine all of my previous tutorials based on MATLAB image processing.
1) Color Detection in Images using MATLAB
This tutorial is about the detection of a specific color among different colors on an image using an amazing tool i.e MATLAB. Color detection becomes necessary sometimes. Like there different cars with same external structure and same specifications but they have different colors. We have to select a red colored car using computerized automated system, to wash it.
Here we need to apply an image processing technique to detect the red color among all of the different colors present at a time. In this tutorial I have take an image having red, green and blue colors in it. I have individually detected each of the colors from this image using MATLAB image processing technique.
- You download the complete simulation here by clicking on the button below.
Download Color Detection in MATLAB using Image Processing
2) Detect Circles in Images using MATLAB
In this tutorial I have explained the methods for the detection of the circles in MATLAB. Its a quite simple technique. The first thing is to choose an image on which the circles are to be detected. Then the second step is the detection of the circles on the selected image. I have used an image of bicycle having two circles i.e. its wheels as shown in the figure on right side.
You can see there are two circles in the image. MATLAB finds the circles first and then shows them to us by detecting them. For this figure MATLAB has found both of the wheels and shown us the detected wheels as white and red dotted line on inner surface of both of the wheels of bicycle.
- You download the complete MATLAB simulation here by clicking on the button below.
Download Detect Circles in Images using MATLAB
3) Image Zooming with Bilinear Interpolation
In this tutorial I have elaborated the technique for the image zooming with bilinear interpolation in MATLAB. Different software e.g. paint and adobe photoshop provides us with the option of zooming the image bu just clicking on the button. In this tutorial I have performed the operation of image zooming in MATLAB using bilinear interpolation. In MATLAB, zooming of an image means that we are increasing the pixels of that image. In order to do so we must have to fill the extra pixels with color of the neighbor pixels. To fill out the extra pixels with some color is usually known as the interpolation. There are a lot of interpolation techniques. I have used a type of linear interpolation named as bilinear interpolation which includes the implementation of interpolation formula on both
x and
y axis. You can see the further details i.e. interpolation formula and its implementation, for this project by clicking on the button below.
- You can download the complete MATLAB simulation for image zooming with bilinear interpolation, just here by clicking on the button below.
Download Image Zooming with Bilinear Interpolation
4) Color Detection in MATLAB Live Video
In this tutorial I have made an algorithm for color detection in MATLAB live video. I have taken a live video from my laptop's camera and then I have detected the specific color from the live video. In order to do this task, you must have to install image processing toolbox in your MATLAB.
I have detected a red color in this tutorial. You can detect any color you want. You have to made a very small change in the code in order to do so. For this tutorial, you can place anything having red color in it, in front of the camera. Algorithm will detect and encircle the red color in that image. The algorithm in working condition is also shown in the figure on right side.
- You can download the complete MATLAB simulation for color detection in MATLAB live video, here by just clicking on the button below.
Download Color Detection in MATLAB Live Video
5) Motion Detection in MATLAB
In this tutorial, I have made an algorithm for the detection of the motion in MATLAB. This project can be used as the security purposes. For hardware purpose IR sensor is used to detect the motion in the surroundings. I have used MATLAB software for the motion detection in the real environment instead. I have used a webcam and then applied a simple algorithm in order to detect the motion in the surroundings.
I have made GUI having different sections on it. on the first axis the image is to be captured and then you need to press Start Comparison button to visualize the change in surroundings. If any change is occurred in the environment or not, corresponding text will be displayed on the GUI at the bottom right corner of the GUI.
- You can download the complete MATLAB simulation for Motion Detection in MATLAB, here by just clicking on the button below.
Download Motion Detection in MATLAB
6) Eye Ball Detection in MATLAB
In this project I have designed an algorithm for Eye Ball Detection in MATLAB. I have designed a Graphical User Interface (GUI) to detect the eye balls from the images loaded into the GUI. Our team has worked very hard to design this algorithm. So, I have not share the simulation for this task for free.
I have imposed a small amount of cost on it. You can easily buy this project by clicking on the button below. The algorithm is designed in MATLAB 2015 version. So, you must have MATLAB 2015 or its later version because it is not backward compatible. As you run the simulation a GUI will be opened on your screen. You just need to browse the image in which eye balls are needed to be detected. Then press the Load button, you will see that eye balls has been detected successfully as shown in the figure on right side.
- You can download the complete MATLAB simulation for Eye Ball Detection in MATLAB, here by just clicking on the button below.
Buy Eye Ball Detection in MATLAB
So, that is all from the tutorial MATLAB Image Processing. I hope you all enjoyed this tutorial.If you face any sort of problem, you can ask me freely anytime in comments without even feeling any kind of hesitation. I will try my level best to entertain you and to sort out your issues in some better way, if possible. I will explore this technique further in MATLAB and on the other software as well in my later tutorials. So, till then, Take Care :)
How to use Print MATLAB
Hello everyone! I hope you all will be absolutely fine and having fun. Today, I am going to share my knowledge about
How to use Print MATLAB. As you all know that the design of an algorithm is not enough until we observe its results too. So, there should be a debugging tool in order to check the performance and accuracy of the designed algorithm. Debugging tool helps us to improve the algorithm’s performance and accuracy too by observing its output again and again. In this tutorial I will tell you about using
print command in MATLB for different purposes. So, in this tutorial I am going to use print command as a debugging tool in order to observe the output of the algorithm. You should also have a look at
how to use MATLAB ?
I am going to use print command to either print the desired statement on the command window in MATLAB or to display the graphs on a figure and to automatically save it on any destination wherever you want to. I will elaborate this command with the help of the different examples later in this tutorial. if you new to MATLAB then you should read
Introduction to MATLAB. So, now let's have a look at How to use Print MATLAB:
How to use Print MATLAB
In the tutorial
How to use Print MATLAB, I will tell you about the use of this command in MATLAB while explaining a lot of examples and by displaying their results. The examples include the printing of the statement on the command window in MATLAB as well as to display the graphs and to save its image.
- Here, I am going to print some statement (the name of our website) on the command window using this particular command in m.file.
- The use of the command fprintf is shown below.
clc % clears the command window
fprintf('www.TheEngineeringProjects.com\n')% prints the desired statement
- Editor also displays that command in the figure shown below.
- You can observe the result of this statement on the command window in MATLAB.
- The result displayed on the command window is shown in the figure below.
- So, that was about how to print the statement on the command window.
- Now, I am going to print the result of some mathematical operations applied on some variables, on command window using the same command.
- I have assigned different values to the two variables a and
- I have calculated their sum and displayed on the command window.
- The commands written on the editor are shown in the figure below.
- The result of the above commands displayed on the command window is shown in the figure below.
- So, that was the description of how to print the results mathematical operations applied on some variables on command window.
- Now, I am going to perform some operations on matrix.
- The source code written in editor of the MATLAB is shown below.
- I have initialized a matrix named as
- I have then displayed that matrix on the command window.
- At the end, I have printed all the values of that matrix on the command window.
- The result of all the above commands displayed on the command window is shown in the figure below.
- First row in the above figure displays the matrix.
- And the second row prints each value of the matrix in next ling using \n.
Graphics Format File
- You need to specify file name and format switch to save your figure as graphics.
- The supported output formats for exporting from MATLAB and switch settings are shown in the table given below.
Print Paper Copy of Figure
In this method a new bar chart will be created and printed to your system default computer. If you do not specify the figure to be printed, then print will use the current figure.
- The source code written on the editor is shown below.
clc
bar(1:10);
print
- The editor window with the code is also shown in the figure below.
- The figure generated from the above code is shown below.
- That was the detailed discussion about using print command as a debugging tool in MATLAB.
So, that is all from the tutorial How to use Print MATLAB. I hope you enjoyed this tutorial. If you face any sort of problems regarding anything, you can ask me freely in comments every time, without even feeling any kind of hesitation. I will try my level best to solve your issues in a better way, if possible. There's another interesting MATLAB Projects named as
Eye Ball Detection in MATLAB. I will explore different software including MATLAB in my next tutorials and will share all of them with you guys as well. So, till then, take care :)
Multi Color Detection in MATLAB
Hello everyone! I hope you all will be absolutely fine and having fun. Today, I am going to share my knowledge about
Multi Color Detection in MATLAB. Color Detection scheme plays a vital role at some places. Like in Image processing technique the detection of specific color among the different colors is necessary to perform some action on it. For example there are three cars of the colors red, blue and green and we want to wash the red car. You should also have a look at
Color Detection in Images using MATLAB because I am gonna use the same code and will add some improvements in it. Moreover, if you are working on Live Videos instead of Images then you should have a look at
Color Detection in Live Video using MATLAB.
For this purpose we need to design an algorithm which is capable of detecting red color among the different colors. Similarly there are a lot of other examples are there to perform the tasks like that. This tutorial will elaborate the step by step explanation of the algorithm designed for multi color detection in MATLAB using Graphical User Interface (GUI). The tutorial consists of two different parts. In first part the GUI will be created while the second part will consist of an algorithm to detect a particular color among the different colors. Further details about the designed algorithm is elaborated in the section below.
Multi Color Detection in MATLAB
Here, in the tutorial
Multi Color Detection in MATLAB, I will explain the step by step description about designing an algorithm for multi color detection in MATLAB GUI. The total project is divide into two parts, GUI will be created in the first part and algorithm designing will be explained in the second part.
- You can download the complete MATLAB GUI simulation here by clicking on the button below.
- Download .rar. file, extract it and enjoy the complete package :)
Download MATLAB Simulation
GUI Design for Multi Color Detection in MATLAB
This section of the tutorial Multi Color Detection in MATLAB will elaborate you all of the steps involved during the design of Graphical User Interface (GUI).All of the steps are given below.
- GUI design consists of several different steps which are explained below.
- GUI consists of the two different panel.
- The left panel is for browsing or loading an image from the laptop or computer.
- Left panel has a button to browse an image, an axis to visualize the loaded image and edit box to view the image's complete path.
- The right panel is designed for color detection for the browsed image.
- Right panel has three different buttons in order to detect red, green and blue colors and an axis to display the detected color on the image loaded in the left panel.
- So that was the detailed description of the GUI, designed for multi color detection in MATLAB.
- Initially designed GUI without panels is shown in the figure below.
- The updated GUI with both the panels with proper tags is shown in the figure below.
Other Image Processing Projects:
Algorithm Design for Multi Color Detection in MATLAB
In this section of the tutorial Multi Color Detection in MATLAB, I will explain you about the design of an algorithm for detecting multi colors from the image loaded into GUI. The algorithm is further divided into two different parts. In the first part image is loaded into the GUI for the detection of multi color. Whereas, the second step consists of the detection of multi colors and its display on the GUI.
- Go to the call back back function of Browse button and just copy paste here, the MATLAB code given below.
global ImageFile
[filename pathname] = uigetfile({'*.jpg';'*.bmp'},'File Selector');
ImageFile = strcat(pathname, filename);
axes(handles.axes1);
imshow(ImageFile) % displays the image on particular axis
set(handles.edit1,'string',ImageFile); %sets the text of the edit box on GUI
- I have first write a line to load the image from its path into the GUI.
- After loading the images I have adjusted an axis on which the image is to be displayed.
- At the end I have set the text of the edit box as the address of the image.
- So that the was the logic to load an image into GUI of MATLAB.
global ImageFile
ImageFile
data = imread(ImageFile);
diff_im = imsubtract(data(:,:,1), rgb2gray(data)); % subtracts the red color from the image
%Use a median filte tFileo filter out noise
diff_im = medfilt2(diff_im, [3 3]);
diff_im = im2bw(diff_im,0.18);
diff_im = bwareaopen(diff_im,300);
bw = bwlabel(diff_im, 8);
stats = regionprops(bw, 'BoundingBox', 'Centroid');
% Display the image
axes(handles.axes2); % axis adjustment
imshow(data) % displays the image with the detected colors
hold on
for object = 1:length(stats)
bb = stats(object).BoundingBox;
bc = stats(object).Centroid;
rectangle('Position',bb,'EdgeColor','r','LineWidth',2)
plot(bc(1),bc(2), '-m+')
a=text(bc(1)+15,bc(2), strcat('X: ', num2str(round(bc(1))), ' Y: ', num2str(round(bc(2)))));
set(a, 'FontName', 'Arial', 'FontWeight', 'bold', 'FontSize', 12, 'Color', 'blue');
end
hold off
- The main part of this code is to subtract the red color from the loaded image and to display it on the axis.
- I have made rectangular areas around the detected colors at the end.
- So that was the description of the algorithm to detect the red colors from the loaded image.
- The final Updated GUI is shown in the figure below.
- The image is to be loaded in the left panel of the updated GUI.
- Loaded image in to the GUI is shown in the figure below.
- Color will be detected in the right panel.
- Red color detected from the loaded image is shown in the figure below.
- Green color detected from the loaded image is shown in the figure below.
- Blue color detected from the loaded image is shown in the figure below.
So that is all from the tutorial Multi Color Detection in MATLAB. I hope you enjoyed this tutorial. If you face any sort of problems, you can freely ask me in comments any time without even feeling any kind of hesitation. Our team will try our level best to entertain you and to solve your issues in some better way, if possible. I will explore MATLAB as well as other software in my later tutorials and will surely share all of them with you guys as well. So, till then, Take Care :)
How to use MATLAB input Function
Hello everyone! I hope you all will be fine and having fun. Today, I am going to share my knowledge about
How to use MATLAB input Function. In this tutorial I would like to tell you about the importance of getting data from the user in MATLAB. If you want to display the data to users, you need to get data from them as well according their requirements. I hope you have read
How to use MATLAB ?
In this way the same source code written in MATLAB will give different result according to the requirements of the each user. So, in other words the source code becomes generic in this way. As we run the program, command window of the MATLAB asks user to enter the desired input. The results on this window are generated according to the
Matlab input given by the user. You should also have a look at Laplace Transform in MATLAB.
How to use MATLAB input Function
Here, in this tutorial I will explain you the importance and the procedure about
How to use MATLAB input Function. The one of the main advantage of getting the data from the user is, the algorithm becomes generic in this way. The different users can get different types of results from the same program according their requirements. The user has to enter the input on the command window and can get the desired results according to the given input.
Getting User Data
- First of all open your MATLAB software and go to the editor in MATLAB.
- Write a simple code in editor as shown below.
clc
x=input('Enter the value of x = ');
y=input('Enter the value of y = ');
x+y
- Move to the command window and observe the results.
- As you Run the program you will automatically move to the command window.
- Command window will ask to enter the value of the first variable, which is x in this case.
- The result of the above program is shown in the figure below:
Note:You should also have a look at these MATLAB projects as well:
- After entering the value of x command window will ask to enter the value of the second variable, which is y in this case.
- The figure shown below displays the above results.
- As you enter the value of y and press Enter, you will be able to see the result of the addition of the both of the variables.
- The result is shown in the figure below.
- Till now, I have performed addition operation on the variables whose values are given by the users and the program shows the different results for each user.
- You can also perform a lot of other operations on these variables.
- Here, I am going to perform basic mathematics operations on these two variables.
- The code for multiplication operation is shown below.
clc %clearing command window
x=input('Enter the value of x = ');%takes the value of x from the user
y=input('Enter the value of y = ');%takes the value of y from the user
product = x*y %performing multiplication
- The input MATLAB code will look something as shown in below figure:
- The result on the command window is shown in the figure below.
- Now, I am going to perform the division operation on the both of the variables.
- The source code for the division operation is shown below.
clc %clears comand window
x=input('Enter the value of x = '); %takes the value of x from the user
y=input('Enter the value of y = '); %takes the value of y from the user
product = x/y %performing division operation
- The result of the above source code is shown in the figure below.
- Similarly you can perform a lot of other operations on the variables whose values are given by the user.
- So, that was the brief discussion about How to use MATLAB input Function.
- Here's the video in which I have explained in detail How to use MATLAB input Function:
So, that is all from the tutorial How to use MATLAB input Function. I hope you enjoyed this tutorial. If you find any sort of problem, you can ask in comments anytime without even feeling any kind of hesitation. I will try my level best to solve your issues in a better way, if possible. You should also have a look at
Introduction to MATLAB. In my next tutorial I will elaborate that how to generate rectangular signals in MATLAB and how to manipulate them. I will further explore MATLAB in my later tutorials by making further projects on it and will share them with all of you as well. So, till then, Take Care :)
How to use MATLAB
Hello everyone! I hope you all will be absolutely fine and having fun. Today, I am going to share my knowledge about
How to use MATLAB. This is an on demand tutorial. The tutorial will help you to learn the the basics of the MATLAB and will elaborate the use of the different tools of it e.g. command window, m.file, Graphical User Interface (GUI) and simulink. Before into the details of this tutorial you must go through
Introduction to MATLAB first for the better understanding of this tutorial. Each of the tools has its own importance while making an algorithm in MATLAB. Command window basically deals with the shorter commands where there is a need of quick execution. Command window shows the result of all of the executed commands if there is no semicolon at the end of the particular statement. You must also have a look at
Declaration of Variables in MATLAB.
MATLAB provides high level of technical computing. It provides an easy to use environment for computation and programming to solve problems and their solutions can be expressed in mathematical symbolic notations. MATLAB can be used for a lot purposes e.g. computational mathematics, simulation, mathematical modeling, engineering graphics, data analysis, prototyping etc. MATLAB works on the basis of matrices whose basic building is an array. MATLAB system has different parts which will be discussed later in this tutorial. MATLAB has a lot of tool boxes in order to provide easiness to the users. Signal processing tool, fuzzy logic tool, control systems tool and simulation tool are its major tools that are used most frequently.
How to use MATLAB
Here in the tutorial,
How to use MATLAB, I will tell you about the basics of the MATLAB and the necessary steps to use the different tools of the MATLAB e.g. command window, GUI, simulink and m.file. First of all I would like to tell you a brief description of the MATLAB software.
Parts of MATLAB
- There are five different main parts of the MATLAB.
- MATLAB Language.
- MATLAB Working Environment.
- Handle Graphics.
- MATLAB Mathematical Functional Library.
- MATLAB Application Program Interface.
- All of these five parts are shown in the figure below.
- The brief description of each of the part is given below.
1) MATLAB Language
It provides high level matrices language. This language includes the features like flow statements, data structures, object oriented programming, input/output etc. It provides the facilities for programming at lower as well as on higher scales. We have posted many Matlab projects in which I have used MATLAB Language, here are few of these projects:
2) MATLAB Working Environment
This part provides set of tools and facilities to the MATLAB users. The facilities include the management of variables in workspace, debugging, m.files and import and export of the desired data. MTALB working environment is shown in the figure below:
3) Handle Graphics
This is a MATLAB system for graphics and it includes image processing and data visualization in two dimensions as well as in three dimensions. It also includes the designing of complete Graphical User Interface in MATLAB. Handle graphics in MATLAB is shown in the figure below:
4) MATLAB Mathematical Functional Library
It has a wide range of computational algorithms from the lower level (e.g. sum, sine, cosine) to the higher level (e.g. matrices inverse, matrices eigen values etc.). Mathematical functional library is shown in the figure below.
5) MATLAB Application Program Interface (API)
It provides you a library to write C programs as well as Fortran programs which interact with the MATLAB. It provides a lot of facilities e.g. MAT files. MATLAB application program interface (API) is shown in the figure below.
- So that was the brief description of the five different parts of the MATLAB.
How to use MATLAB Command Window
Here in this section of the tutorial How to use MATLAB, I will tell you about the the steps to use the command window in MATLAB and its importance in different circumstances. Command window is used to display the results of the algorithm immediately. When you do not specify an output variable whose values is desired to be obtained, then MATLAB uses a variable named as
ans which is the short form of the word
answer. This step is shown in the figure below.
Command window is the window which displays the output in non-graphic form. The symbol
>> shows that the MATLAB is ready for the input to be entered.
- Here I would like to show you the use of command window.
- I have declared three different variables named as a,b and c.
- I have stored the value of the sum of first two variables in the third variable.
- The result is shown in the figure below.
- Command window will only display the result of that statement which has no terminating semi colon.
- Now I am going to compute the values of trigonometric functions.
- The result is shown in the figure below.
- So that was the overview of how to use MATLAB command window.
How to use MATLAB m File
Here in this section of the tutorial How to use MATLAB, I will tell you about how to use the m.file in MATLAB. It is also known as the editor in MATLAB. You must also visit
How to Create m.file in MATLAB for the better understanding.
- I am going to add the simple two of the variables and storing it into the third variable while creating m.file in MATLAB.
- The result of the above description is shown in the figure below.
- Now, I am going to plot a simple sinusoidal signal while creating an m.file in MATLAB.
- The source code is shown in the figure below.
- The resulted plotted sinusoidal signal is shown in the figure below.
- So, that was the brief description about How to create or use m.file in MATLAB.
Note:These are few MATLAB projects in which I have written the MATLAB code in m File:
How to use MATLAB Simulink
Here in this section of the tutorial How to use MATLAB, I will explain you that how to use this amazing tool of the MATLAB. It represents the source code in terms of different blocks. First of all I would like to tell you that how to open the simulink library in MATLAB.
- You need to follow the steps given below.
- Open your MATLAB software, a new window with different MATLAB sections will be appeared on your screen.
- Click on the encircled button as shown in the figure below.
- As you press this button, a new window having simulink library in it, will be opened on your screen.
- The simulink library is shown in the figure below.
- Now, I am going to generate two simple sinusoidal signal in MATLAB simulink.
- Press Ctrl+N and a new window will appear upon which we need to place the desired blocks.
- Go to the Sources and select the sine wave block from it.
- Drag this blcok and drop it on the second window as shown in the figure below.
- Similarly copy and paste the same block.
- Here I am going to add the both of the sinusoidal signals having phase shift of 90 with each other.
- I have placed a scope to observe the addition of the both of the signals visually.
- All of the above steps are shown in the figures below.
- The selection of the add block is shown in the figure below.
- The selection of the scope is shown in the figure below in order to visualize the results.
- Now, the complete source code for the addition of two sinusoidal signals is shown in the figure below.
- After making this algorithm just run the program by clicking on the button encircled in the above figure.
- Double click on the Scope in order to visualize the desired result.
- The result of the addition of both the signals is displayed on the scope and is shown in the figure below.
- So, that was the brief description about how to open and use simulink library in MATLAB.
How to use MATLAB GUI
In this section of the tutorial How to use MATLAB, I will explain you about how to create Graphical User Interface (GUI) in MATLAB and how to operate it. GUI displays the desired results visually which helps us in better understanding of the algorithm instead of observing the results in analog form or in digital data. It also provide better external look to the designed algorithm. You should also have a look at
How to Create a GUI in MATLAB. I have designed many projects using GUI in MATLAB so you go through these below projects:
In order learn that how to perform different tasks using GUI in MATLAB, you need to follow the below steps:
- Go to the command window and type guide there.
- The step is shown in the figure below.
- When you press Enter a new window will be appeared on your screen.
- Go to the Create New GUI and select the blank GUI and hence a new GUI will be opened and its source code will be generated automatically in m.file of the MATLAB.
- The above steps are shown in the figure below.
- Now, pres OK button and a GUI will be appeared on your screen.
- The GUI appeared on the screen is shown in the figure below.
- Now you can pick and place the buttons, tables and graphs from the left side of the GUI.
- I picked a graph, a table and a button from the left bar of the GUI.
- All of the above steps are shown in the figure below.
- That was the overview of the basics of the MATLAB.
So that is all from the tutorial How to use MATLAB. I hope you enjoyed this tutorial. If you face any sort of problem regarding anything, you can anytime ask me in comments, freely, without even feeling any kind of hesitation. I will try my level best to solve you issues in some better way, if possible. I will explore MATLAB and other software and hardware too in my later tutorials later and will surely share them with all of you guys as well. So, till then, Take Care :)