Skip to main content

Posts

Showing posts from January, 2016

Rejecting the applications that are not fit using Matlab

Program Let us say that you have got a client who is a HR Manager of a company. Understand the situation below. The company has given a notification in a newspaper for an opening and around 10 people has turned up. The selection process was three stages out of which for two stages your client want you to sort out the applicants. In the first stage a question paper for 5 marks is given and in the second stage a question paper for 5 marks is given while third stage is interview. They store the marks of the candidates in a file which has the data which looks as follows: Id Number Paper 1 Paper 2 1 1.5317 4.6950 2 2.5425 4.3797 3 2.5539 2.7508 4 4.0881 3.1124 5 3.9742 2.9352 6 3.2216 1.0387 7 1.8930 1.5062 8 4.0579 2.3546 9 2.6641 1.1524 10 1.7536 4.2215 such that it h

Prompt the user to enter a number, a random number of times using Matlab

Problem Write a script that will:  Generate a random integer in the range from 2 to 5  Loop that many times to  Prompt the user for a number  Print the sum of the numbers entered thus far with one decimal place There are many signal processing applications. Voltages , currents , and sounds are all examples of signals studied in a diverse range of disciplines such as biomedical engineering , acoustics , and telecommunications . Sampling discrete data points from a continuous signal is an important concept. Solution This problem has been taken from the book A practical introduction to Matlab by Stormy Attaway We will solve this problem by using Matlab for loop and Matlab while loop. Also we will generate a random integer in the matlab using the rand function in Matlab within a given interval. Some of the concepts you need to know to solve this problem are as follows: 1) rand function in Matlab 2) for loop , youtube for loop 3) while loop , youtube while loop 4

Creating Multiplication tables using Matlab

Program Write a program to generate Multiplication tables of a given number using Matlab. Also generate Multiplication table for all numbers at once, like the one below: Multiplication Table 20 x 20 To know more about the multiplication tables you can refer: Multiplication Table/Chart - Ncalculators Multiplication Table - Wikipedia Solution Program 1: We will ask the user to give input of a number. Then we will use a for loop to print out the multiplication table of the corresponding number.  Program 2: We will write a program using functions. Program 3: We will create 10x10 multiplication table using the solution given here: Stack Overflow . Program 4: Generate 10x10 multiplication table using the nested for loops. You can refer to the explanation section for better understanding of the program. Some of the concepts you need to know to solve this problem are as follows: 1) input function in Matlab 2) for loop in Matlab  - This website has a very good explana

Check whether if the flow is laminar, transitional or turbulent with reynolds numbers using Matlab

Problem Reynolds number is a dimensionless property, it is used to find the flow type of the fluid. This data is useful is Fluid Mechanics, Heat and Mass transfer and many other subjects. But for our discussion the user will enter the Reynold's number and we will determine the type of the flow using the table below. We will accomplish the task using Matlab. Flow Type Renolds Number(Re) Laminar Re< 2300 Transient 2300<Re<4000 Turbulent Re>4000 If you want to know more about Reynolds number then refer to the fo

Check Pythagorean triplet using Matlab

Program We know that the Pythagorean is an equation which satisfies the following condition: a 2  + b 2 = c 2 Write a program with Matlab, which takes the user input of the numbers and checks if the above condition is satisfied. If the condition is satisfied then display the success to the user. Right angle triangle Solution We take the user input and then use the if else statement to check if the user has entered three number which are in accordance to the Pythagorean theorem and display the success using the fprintf in Matlab. Some of the concepts you need to know to solve the above problem are as follows: 1) User input using input function 2) if else statement in Matlab 3) fprintf in Matlab Program 1 2 3 4 5 6 7 8 9 a = input( 'Enter length of Opposite side(a): ' ); b = input( 'Enter the length of Adjacent side(b): ' ); c = input( 'Enter the length of Hypotenuse(c): ' ); if a^ 2 + b^ 2 == c^ 2 fprintf( 'Thats a py

Find eccentricity and area of ellipse using Matlab

Problem Find the area and eccentricity of the ellipse using simple if else and also using functions in Matlab. The relations for eccentricity and area of ellipse are given below: Area of ellipse equation Eccentricity of ellipse formula To know more about ellipse you can see from here: 1) Math is fun 2) What is ellipse - cut-the-knot Solution As we have already seen many basic programs lets make this a little bit difficult about 0.1 star difficulty from other problems. Remember we are now not adding difficulty in the Matlab program but we are adding difficulty in terms of math. We will see more difficult problems in Matlab soon. Stay tuned for difficult problems. In this problems we will ask the user to give the value of a and b. Then we will check if the user has not entered any value of b less than zero. Because length cannot be negative. And similarly we will check if the user has not entered the value of a less than or equal to 0. Because as the given equat

Volume of pyramid in using Matlab

Problem Write a script to calculate the volume of a pyramid, which is 1/3 * base * height,  where the base is length * width. Prompt the user to enter values for the length,  width, and height, and then calculate the volume of the pyramid. When the user  enters each value, he or she will then also be prompted for ‘i’ for inches or ‘c’ for  centimeters. (Note: 2.54 cm  = 1 inch.) The script should print the volume in cubic  inches with three decimal places. As an example, the output format will be: This program will calculate the volume of a pyramid. Enter the length of the base: 50 Is that i or c? i Enter the width of the base: 6 Is that i or c? c Enter the height: 4 Is that i or c? i The volume of the pyramid is xxx.xxx cubic inches. Solution This problem has been taken from the book A Practical introduction to Matlab by stormy Attaway . This is a must read book for Matlab programmers. This will make your path to success in Matlab easy and yes you will become a pro in M