MATLAB tutorial covering how to program in MATLAB code to create a script or function, including a for loop using the MATLAB Editor. Download code and watch other videos at mathworks.com

Note: This is a user submitted video under “User Submitted” Category. Although the submitted content is moderated, RealityPod does not guarantee the accuracy of information provided in posts of this particular category.

Using the colon operator (e.g. x=1:1000), generates as row vector.

The example plots multiple lines by storing all the data in a matrix and calling the plot command once. When you plot a matrix, the plot command treats each *column* as a seperate line series to plot, therefore the data had to be stored as columns.

You could also have transposed the whole matrix before plotting, or plotted each row vector one at a time in a for loop.

hi i hav to design 8 order iir using 0rder 2 cascaded i hav found the quantized coeff(24) using sos function. Could u pls help us how to cascade using matlab coding.have we to pairing the pole-zero or matlab itself does itself. Pls help

You need to convert the digit to the pair of frequencies (look at the layout of your phone dial pad) , then you need to generate two sine waves for each. Look at the sine wave function in MATLAB. There are also lots of internet pages on this topic.

I’m trying to create a Matlab function (M-File) that will output the low (flow) and high (fhigh) frequency components of a DTMF signal given the numeric symbol (x) (* and # not included).

Each pair of tones contains one frequency of the low group (697 Hz, 770 Hz, 852 Hz, 941 Hz) and one frequency of the high group (1209 Hz, 1336 Hz, 1477Hz) and represents a unique symbol. What should I do first?

the format is this:
function [flow fhigh]=mydtmf(x)

See the help for the function. Primes(N) does not return the first N prime numbers, it returns all prime numbers less than or equal to N. Try a while loop, increasing N until you get 50 numbers.

hi im trying to write the first 50 prime numbers but i cannot seem to get it to work
i want all 50 but as i keep putting p=primes(50) i jst get 14 values

You can use the method described in the video to create a function with two inputs and one output. You provide the two values when you call it. I’m not sure what you man by “ask.” Have you looked at the “input” command?

let’s say i wanna write a program that compute the area of the rectangular , and i want the dimensions i enter to be (a & b) as my input variables. how can i do that ?
in another word. i want to write a prog that ask me about the dimension i then it computes the area once i give it the dimensions.

anyone know how to use the “set” function? tried reading the help but didnt understand it… thanks

Googling working+with+arrays+matlab should find you some good resources such as the “Working with Arrays” video.

i’m trying to remove the top half of the rows of a row-by-col vector/array. can anyone tell me how that’s done in a function?

the best part of these videos is your voice. man, it’s incredible.

Using the colon operator (e.g. x=1:1000), generates as row vector.

The example plots multiple lines by storing all the data in a matrix and calling the plot command once. When you plot a matrix, the plot command treats each *column* as a seperate line series to plot, therefore the data had to be stored as columns.

You could also have transposed the whole matrix before plotting, or plotted each row vector one at a time in a for loop.

at 2:59 why did you make x =1:1000 a column vector?

prety good thats what i need functions for my game maker program and if i get a robot kit.

hi i hav to design 8 order iir using 0rder 2 cascaded i hav found the quantized coeff(24) using sos function. Could u pls help us how to cascade using matlab coding.have we to pairing the pole-zero or matlab itself does itself. Pls help

You need the Symbolic Toolbox to (symbolically) differentiate functions (to get 3x^2 -2x in this case).

how can diffirentiate this functin x^3-x^2-1 using diff function in matlab..

you r a good guy! if i have problem,i will pray your help!O(?_?)O~

You need to convert the digit to the pair of frequencies (look at the layout of your phone dial pad) , then you need to generate two sine waves for each. Look at the sine wave function in MATLAB. There are also lots of internet pages on this topic.

I’m trying to create a Matlab function (M-File) that will output the low (flow) and high (fhigh) frequency components of a DTMF signal given the numeric symbol (x) (* and # not included).

Each pair of tones contains one frequency of the low group (697 Hz, 770 Hz, 852 Hz, 941 Hz) and one frequency of the high group (1209 Hz, 1336 Hz, 1477Hz) and represents a unique symbol. What should I do first?

the format is this:

function [flow fhigh]=mydtmf(x)

any help would be deeply appreciated.

thank you so much

See the help for the function. Primes(N) does not return the first N prime numbers, it returns all prime numbers less than or equal to N. Try a while loop, increasing N until you get 50 numbers.

hi im trying to write the first 50 prime numbers but i cannot seem to get it to work

i want all 50 but as i keep putting p=primes(50) i jst get 14 values

I think he’s meaning more in the way of a GUI.

As in a program that when ran asks for variables and then calculates the area.

all common sense

if you do it often ðŸ™‚

Thank you very much for ur fast reply…

matLab*

wIndow*

That feature is not available in MATLAB 7.0.1. See the “Functions by category” section in the help browser to see all available functions.

i m using matab 7.0.1

on my command wondow, there is no “fx”on left side… can anybody tell me how i can get it… thanks…

You can use the method described in the video to create a function with two inputs and one output. You provide the two values when you call it. I’m not sure what you man by “ask.” Have you looked at the “input” command?

let’s say i wanna write a program that compute the area of the rectangular , and i want the dimensions i enter to be (a & b) as my input variables. how can i do that ?

in another word. i want to write a prog that ask me about the dimension i then it computes the area once i give it the dimensions.

i dont have an idea about algorithms and C#, so can i learn MATLAB before other?

waiting for reply

I’ve already finished C. Think i can do MatLab?