Swordrock's Blog

Just another WordPress.com site

Matlab-2 Functions


CREATİNG SCRİPTS AND FUNCTİONS

To type the codes,we use editor .we begin by entering the  first codes :

a= input (‘first number’);        //  we want user to enter a value

b = input (‘second number’);   // we want user to enter b value

disp ([‘their sum is’ num2str(a+b)])   // program displays sum

disp ([‘their product is’ num2str(a*b) ])  // program displays product

#one of the most common problem is wrong script being run or when the computer can not find the program you have just entered .

#you can use ‘type’ command to list the program entry :

Type twonums

# you can also list the files in the current directory with ‘dir’ command

#you can find the path of the program using ‘which’ command

FUNCTİONS

These codes take inputs and return outputs    :

function [output] = xsq (input)        // we name the function

output = input.^2     // we write the calculation process

and now we are ready to write for x values to be calculated  .

>> x = 1:10 ;

>> y = xsq (x);

>> y

y =

1     4     9    16    25    36    49    64    81   100

Note : input and output variables are two local variables

e.g : suppose we want top lot the function z = x^2 + y^2  and then we write

function [output]  = func (x,y) ;

output = x.^2 + y.^2 ;

then we will enter the values    as

>> x=5; y=10;

>> func (x,y)

ans =

125

>>

Supppose now we want to construct the squares and cubes done by a function :

Function [sq,cube] = xpowers (input)

Sq = input.^2;

Cube=input.^3;

>> x = 1:10 ;

>> [xsq,xcub] = xpowers (x)

This gives us following results :

xsq =

1     4     9    16    25    36    49    64    81   100

xcub =

Columns 1 through 9

1           8          27          64         125         216         343         512         729

Column 10

1000

The output is two row vectors

#a function can have multiple inputs and outputs as :

Function [out1,out2] = multi (in1,in2,in3)

Out1 = in1 + max (in2,in3) ;

Out2 = (in1+in2+in3 )/3

x1 = 2; x2 = 3; x3 = 5;

[y1,y2] = multi(x1,x2,x3);

y1, y2

#inputs and outputs dont have to be the same size  :

Function [output]  = sumsq (x)

Output = sum (x.^2)

> x = 1:7;

>> sumsq (x);

>> sumsq (x)

ans =

140

>>

#if we want to use multiple matrices as inputs we write is as :

A = [1 2 3 ; 4 5 6 ] ;

Sumsq (A)

This is the sumsq of the columns

ans =

17    29    45

Ağustos 30, 2010 Posted by | Matlab | Yorum bırakın

Automotive Electronic


AUTOMOTİVE EMBEDDED SYSTEMS

Hi Today ,

How is it going ? Today i plan to make an introduction to Automotive Electronics  . Electronic systems are getting bigger and bigger day by day while mechanical systems fall off .


Embedded systems in the automotive area consists of ;

• In-vehicle architectures

• Multipartner development processes (subsystem integration, product line

management, etc.)

• Software engineering methods

• Embedded communications

• Safety and dependability assessment: validation, verification, and testing

Some electronic functions that used in automobiles are navigation, adaptive control, traffic information, traction control, stabilization control, and active safety systems.

Today, up to 2500 signals (i.e., elementary information such as the speed of the vehicle) are

exchanged through up to 70 electronic control units (ECUs) on five different types of networks.

electric car Tesla

İn automotive industry,there is 3 principal players :

• Vehicle manufacturers

• Automotive third-part suppliers

• Tool and embedded software suppliers

You see , there is lots of app. of electronics for Automotive sector . See you .

Ağustos 28, 2010 Posted by | Automotive Electronics | , , , , | Yorum bırakın