Matlab examples - the blog...

Here are some new examples and applications that I have added to my website. They try to clarify the use of some instructions and functions in Matlab. I hope you find them useful...

3D Plot Part 2 - working with Matlab

The 3D plot functions intended for plotting meshes and surfaces 'mesh' and 'surf', and their several variants 'meshc', 'meshz', 'surfc', and 'surfl', take multiple optional input arguments, the most simple form being 'mesh(z)' or 'surf(z)', where z represents a matrix. See these examples...

Continue reading "3D Plot Part 2 - working with Matlab"

Polynomials in Matlab

Polynomials are used so commonly in algebra, geometry and math in general that Matlab has special commands to deal with them. The polynomial 2x4 + 3x3 − 10x2 − 11x + 22 is represented in Matlab by the array [2, 3, -10, -11, 22] (coefficients...

Continue reading "Polynomials in Matlab"

Polynomial Regression in Matlab - easy least squares fitting

We'll demonstrate how to work out polynomial regression in Matlab (also known as polynomial least squares fittings)...

Continue reading "Polynomial Regression in Matlab - easy least squares fitting"

Periodic Function - some codes without special toolboxes in Matlab

A periodic function repeats its values in regular periods or intervals. We explore codes for square and sawtooth waves without any special toolbox needed...

Continue reading "Periodic Function - some codes without special toolboxes in Matlab"

Calculating BMI - another GUI in Matlab

In this project, we are going to develop a GUI in Matlab to calculate the BMI (body mass index). We are going to introduce the radio button...

Continue reading "Calculating BMI - another GUI in Matlab"

Numerical Gradient - code in Matlab

We are going to include the concepts in our Derivative function created before, to develop a Matlab function to calculate the gradient of a multidimensional scalar function. The function is going to have the following functionality...

Continue reading "Numerical Gradient - code in Matlab"

Polygon Area - calculate with Matlab

This program calculates a polygon area, using Matlab. You must supply the x and y coordinates of all vertices. Coordinates must be entered in order of successive vertices...

Continue reading "Polygon Area - calculate with Matlab"

T statistic - Student's t-distribution Test in Matlab

This algorithm performs the t statistic and degrees of freedom for Student’s distribution, in Matlab code. The calculations can be based on any one of these three hypotheses...

Continue reading "T statistic - Student's t-distribution Test in Matlab"

Permutations and Combinations - calculate its number in Matlab

This algorithm (code in Matlab) calculates the number of permutations and combinations of N objects taken D at a time. The full Matlab code is...

Continue reading "Permutations and Combinations - calculate its number in Matlab"

Scilab 3D Plot

Create your first Scilab 3D Plot with these functions. See about plot3d, meshgrid and others...

Continue reading "Scilab 3D Plot"

Calculate Square Feet - online spreadsheet

How to calculate square feet - see this online converter for feet and inches...

Continue reading "Calculate Square Feet - online spreadsheet"

Callback Function - GUIs in Matlab

In this article we’re going to build-up a simple adder. Our adder (by means of relevant callback function s) is going to have two ‘edit text’ components, two ‘static text’ components, and one ‘push button’ element.

Continue reading "Callback Function - GUIs in Matlab"

Matlab Plot - using stems (vertical lines) for discrete functions

In this example, we study the Matlab plot 'stem' instruction to illustrate functions. It draws vertical lines (with little circles on the tip) proportional to the value of the function at that horizontal value...

Continue reading "Matlab Plot - using stems (vertical lines) for discrete functions"

Smith Chart using Matlab

The Smith chart is a graphical tool designed for engineers specializing in RF to solve problems related to transmission lines and matching circuits....

Continue reading "Smith Chart using Matlab"

Recursion - a conceptual example in Matlab

Recursion is a kind of tricky and smart construction which allows a function to call itself. The Matlab programming language supports it...

Continue reading "Recursion - a conceptual example in Matlab"

Nodal Analysis - learn about KCL and solve it easily with Matlab

How a nodal analysis can let you find voltages in an electrical circuit. Use this math software to work out the arithmetic operations...

Continue reading "Nodal Analysis - learn about KCL and solve it easily with Matlab"

Exponential Regression with Matlab

We’ll work with exponential regression in a curve fitting in Matlab. The following three methods find the coefficients of an equation for an exp. curve...

Continue reading "Exponential Regression with Matlab"

Curve Fitting in Scilab

We show how curve fitting is done in Scilab. We show the polyfit and polyval functions equivalent to Matlab's...

Continue reading "Curve Fitting in Scilab"

Scilab Commands and Types

Basic Scilab commands and data types are introduced with basic examples, see these descriptions...

Continue reading "Scilab Commands and Types"

Half-life Calculator - Exponential Decay

This Half-life calculator is used to know the period of time it takes for a substance undergoing decay to decrease by half...

Continue reading "Half-life Calculator - Exponential Decay"