Sunday, October 30, 2011

Initiating And Managing An Energy Management Program

Once a corporate decision has been made to initiate an energy management program, a special management structure within the company's organizational framework needs to be created, in view of the special role of energy as a common input across different divisions, departments and sections.

The energy management structure will depend on the size of the enterprise, its functions organization and its manufacturing activities. In large enterprises having several plants, an energy manager reporting to the plant manger and to the corporate energy manager would be responsible for the energy management coordinators in each division. At the department level, the most effective practice is to make a supervisor responsible for the energy management program.

The structure in medium size companies could be similar to that for a single plant in large companies. In small companies, it may not be necessary to have an energy manager at all. This role could be assigned
to any of the mangers responsible for engineering, maintenance or production, or to a senior staff member.

A useful practice is for the energy managers and coordinators to be assisted by committees consisting of representatives of various functional areas such as engineering, maintenance, utilities, production, etc. These committees would assist in developing programs and  formulating plans, serve as a channel for communication back to personnel in their functional areas, and also serve as a forum for review and generation of ideas.

while considerable management effort is expended in monitoring  raw material consumption or production output, very little or no real attention is generally paid to monitoring energy consumption. 

It is generally ignored in the belief that the energy use cannot be controlled. A focal point in the form of energy manager would be very essential, particularly in large organization. plant energy management programs should be set up to include: 

  • Audits of energy consuming activities, to document clearly all facets of energy use and to identify conservation opportunities.
  • Target/goals for energy efficiency improvement, which will be based on the initial plant audits, and which will include careful consideration of implementation schedules.
  • Monitoring of energy consumption and related production activities, on a regular basis, in order to check on progress towards targets, to identify problem areas at an early stage, and to develop modified targets for year to year, as appropriate.  
  • Training programs and the availability of technical and engineering information to encourage energy efficiency, and to provide employees with the needed skills to achieve improved performance.
  • Development of capital investment programs oriented to improved energy efficiency, including better control systems for operating plants.
  • Comprehensive and clear reporting systems including financial controls and accountability for energy efficiency performance within appropriate departments or subdivisions for the plant, including the analysis of variations in the actual and expected performances.

Organising An Energy Management Program

Basically, Management is the effective utilization of human and material resources to achieve stated objectives. Effective energy management within an industrial enterprise requires:




  • commitment of all and particularly the active commitment of top management to authorize the necessary resources. 
  • communications across all levels in the company, from the highest management levels to the operating personnel and shift workers. 
  • A structure within the company which results in properly identified responsibilities and lines of authority. 
  • Involvement of personnel at all levels in the setting of energy efficiency improvement  goals, and in the improvement of operating standards and performance generally.
  • A focal point  for all energy related matters, and involvement of decision makers of the company. 
  • Expertise in all technical and economic matters relating to energy use.
The continuing commitment, concern and interest of top management in energy management are essential pre-requisites for a successful program. The appointment of energy management is a recent innovation. The Energy manager usually has overall plant or company responsibility for energy supply and energy use, and reports to senior management. He would normally be responsible for the co-ordination and direction of the plants energy conservation program. 

Principles Of Energy Management

Energy management is to provide the manufacturing plants with measured analysis of their consumption and costs, and to provide the plants with the information leading to areas where energy saving opportunities may exist.


Energy management broadly involves two aspects-energy conservation and energy substitution.


      Energy conservation can be taken to be the reduction in the amount of energy consumed in manufacturing a given quantity of product or providing a particular service. Conservation does not mean reducing manufacturing output or doing without services previously enjoyed: it simply means utilizing available energy resources more efficiently. Energy substitution is concerned with replacement of one fuel by more abundant and /or cheaper fuels. A broad understanding and appreciation of some general principles is important:




  • The manner and extent of all energy use should be examined, including the appropriateness of the process/plant items used and the size of the plant item. This examination should, of course, be carried out to the level of details justified by the cost of energy consumed in the corresponding stage of the process. Initially, most effort should be directed towards energy intensive process.
  • An essential element of energy conservation is the systematic measurement of plant energy and material flows. consistent units and definitions should be used if measurements and comparisons with other processes are to be meaningful.
  • In order to carry out accurate energy and material flow measurements, the use of properly calibrated and maintained instrumentation is necessary. Adequate instrumentation is required for both diagnostic "energy audits" and for the optimum control of energy use during normal plant operations.
  • Process waste, such as the production of off grade products, is waste of energy and other important elements of manufacturing cost. Reduction in waste is particularly important where the materials involved have high intrinsic energy contents. Metals, cement, glass, paper, plastics & refractories are examples of high intrinsic materials.
  • Much conservation work is concerned with trying to achieve the same process transformation with a lower input of energy, or attempting to increase the amount of work by a given amount of energy input. Most process energy is lost ultimately to the outside environment in the form of heat. The maximum amount of useful work should be obtained at each stage of temperature or pressure reduction in the process. Sources of heat loss should be identified and the process examined to see if the heat loss can either be prevented or recovered for lower grade process use.
  • Each individual energy conservation saving should be analyzed to ensure that it does not cause process changes which result in an increase in the overall amount of energy used or detrimental effects in the product or production rate. 
  • Some energy conservation improvements require investment in new equipment. Investment in such equipment is likely to be inhibited if there is not an appropriate economic framework and guidelines for the evaluation of energy conservation projects.
  • Much energy conservation can be achieved by the cumulative effect of many small efficiency improvements. Although it is sometimes possible to identify a few major improvement areas, including many individually small items may be the optimum approach.

Monday, October 17, 2011

Queen for 20th century

Naruhito

 Grace Kelly 
  Diana
  Rania's charisma 
 Gayatri Devi
 Kate Middleton

.


        Jetsun Pema

Saturday, October 15, 2011

Nuclear energy

It is the potential energy present in the nucleus of an atom , due to forces between the fundamental particles.

For utilization of any type of potential energy, it has to be converted to kinetic energy by some device, since work is done only by bodies possessing kinetic energy

Chemical Energy

It is the potential energy present in a substance due to forces between atoms which form the molecules of the substance. during a chemical change, there is change in chemical energies of substances.

Identification of Heart Stroke




STROKE: Remember The 1st Three Letters... S.T..R ...

My friend sent this to me and encouraged me to post it and spread the word. I agree. If everyone can remember something this simple, we could save some folks. 

STROKE IDENTIFICATION:
During a party, a friend stumbled and took a little fall - she assured everyone that she was fine and just tripped over a brick because of her new shoes. (they offered to call ambulance)

They got her cleaned up and got her a new plate of food - while she appeared a bit shaken up, Ingrid went about enjoying herself the rest of the evening. Ingrid's husband called later telling everyone that his wife had been taken to the hospital - (at 6:00pm , Ingrid passed away.)
She had suffered a stroke at the party . Had they known how to identify the signs of a stroke, perhaps Ingrid would be with us today.

Some don't die. They end up in a helpless, hopeless condition instead. It only takes a minute to read this...

STROKE IDENTIFICATION:

A neurologist says that if he can get to a stroke victim within 3 hours he can totally reverse the effects of a stroke...totally. He said the trick was getting a stroke recognized, diagnosed, and then getting the patient medically cared for within 3 hours, which is tough.

RECOGNIZING A STROKE

Remember the '3' steps, STR . Read and Learn!
Sometimes symptoms of a stroke are difficult to identify. Unfortunately, the lack of awareness spells disaster.
The stroke victim may suffer severe brain damage when people nearby fail to recognize the symptoms of a stroke.
Now doctors say a bystander can recognize a stroke by asking three simple questions :

S * Ask the individual to SMILE ..
T * = TALK. Ask the person to SPEAK A SIMPLE SENTENCE (Coherently) (eg 'It is sunny out today').
R * Ask him or her to RAISE BOTH ARMS .

If he or she has trouble with ANY ONE of these tasks, call the ambulance and describe the symptoms to the dispatcher.

NOTE : Another 'sign' of a stroke is
1. Ask the person to 'stick' out their tongue.
2. If the tongue is 'crooked', if it goes to one side or the other that is also an indication of a stroke.

A prominent cardiologist says if everyone who gets this e-mail sends it to 10 people; you can bet that at least one life will be saved.a


Sunday, October 9, 2011

MATLAB PROGRAMMING TIPS


Introduction

This section is a categorized compilation of tips for the MATLAB programmer. Each item is relatively brief to help you browse through them and find information that is useful. Many of the tips include a reference to specific MATLAB documentation that gives you more complete coverage of the topic. You can find information on the following topics:
For suggestions on how to improve the performance of your MATLAB programs, and how to write programs that use memory more efficiently, see Improving Performance and Memory Usage


Syntax Help

For help about the general syntax of MATLAB functions and commands, type
help syntax

Command and Function Syntaxes

You can enter MATLAB commands using either a command or function syntax. It is important to learn the restrictions and interpretation rules for both.
functionname arg1 arg2 arg3               % Command syntax
functionname('arg1','arg2','arg3')        % Function syntax
For more information: See Calling Functions in the MATLAB Programming Fundamentals documentation.

Command Line Continuation

You can continue most statements to one or more additional lines by terminating each incomplete line with an ellipsis (...). Breaking down a statement into a number of lines can sometimes result in a clearer programming style.
sprintf ('Example %d shows a command coded on %d lines.\n', ...
          exampleNumber, ...
          numberOfLines)
Note that you cannot continue an incomplete string to another line.
disp 'This statement attempts to continue a string ...
      to another line, resulting in an error.'
For more information: See Entering Long Statements in the MATLAB Desktop Tools and Development Environment documentation.

Completing Commands Using the Tab Key

You can save some typing when entering commands by entering only the first few letters of the command, variable, property, etc. followed by the Tab key. Typing the second line below (with T representing Tab) yields the expanded, full command shown in the third line:
f = figure;
set(f, 'papTuT,'cT)                   % Type this line.
set(f, 'paperunits','centimeters')    % This is what you get.
If there are too many matches for the string you are trying to complete, you will get no response from the first Tab. Press Tab again to see all possible choices:
set(f, 'paTT
PaperOrientation   PaperPositionMode  PaperType     Parent
PaperPosition      PaperSize          PaperUnits
For more information: See Tab Completion in the Command Window in the MATLAB Desktop Tools and Development Environment documentation

Recalling Commands

Use any of the following methods to simplify recalling previous commands to the screen:
  • To recall an earlier command to the screen, press the up arrow key one or more times, until you see the command you want. If you want to modify the recalled command, you can edit its text before pressing Enter or Return to execute it.
  • To recall a specific command by name without having to scroll through your earlier commands one by one, type the starting letters of the command, followed by the up arrow key.
  • Open the Command History window (View > Command History) to see all previous commands. Double-click the command you want to execute.
For more information: See Recalling Previous Lines and Command History Window in the MATLAB Desktop Tools and Development Environment documentation.
If you have typed a command that you then decide not to execute, you can clear it from the Command Window by pressing the Escape (Esc) key.

To suppress output to the screen, end statements with a semicolon. This can be particularly useful when generating large matrices.
A = magic(100);     % Create matrix A, but do not display it.

Using the Help Browser

Open the Help browser from the MATLAB Command Window using one of the following:
  • Click the question mark symbol in the toolbar.
  • Select Help > Product Help from the menu.
  • Type the word doc at the command prompt.
Some of the features of the Help browser are listed below.
FeatureDescription
Product FilterEstablish which products to find help on.
ContentsLook up topics in the Table of Contents.
IndexLook up help using the documentation Index.
SearchSearch the documentation for one or more words.
DemosSee what demos are available; run selected demos.
FavoritesSave bookmarks for frequently used Help pages.

For more information: See Finding Information with the Help Browser in the MATLAB Desktop Tools and Development Environment documentation.

Help on Functions from the Help Browser

To find help on any function from the Help browser, do either of the following:
  • Select the Contents tab of the Help browser, open the Contents entry labeled MATLAB, and find the two subentries shown below. Use one of these to look up the function you want help on.
    • Functions — Categorical List
    • Functions — Alphabetical List
  • Type doc functionname at the command line.

Help on Functions from the Command Window

Several types of help on functions are available from the Command Window:
  • To list all categories that you can request help on from the Command Window, just type help
  • To see a list of functions for one of these categories, along with a brief description of each function, type help category. For example, help datafun
  • To get help on a particular function, type help functionname. For example, help sortrows

Topical Help

In addition to the help on individual functions, you can get help on any of the following topics by typing help topicname at the command line.
Topic NameDescription
arithArithmetic operators
relopRelational and logical operators
punctSpecial character operators
slashArithmetic division operators
parenParentheses, braces, and bracket operators
precedenceOperator precedence
datatypesMATLAB classes, their associated functions, and operators that you can overload
listsComma separated lists
stringsCharacter strings
function_handleFunction handles and the @ operator
debugDebugging functions
javaUsing Sun Java from within the MATLAB software.
fileformatsA list of readable file formats
changeNotificationMicrosoft Windows directory change notification

Paged Output

Before displaying a lengthy section of help text or code, put MATLAB into its paged output mode by typing more on. This breaks up any ensuing display into pages for easier viewing. Turn off paged output with more off. Page through the displayed text using the space bar key. Or step through line by line using Enter or Return. Discontinue the display by pressing the Q key or Ctrl+C.

Writing Your Own Help

Start each program you write with a section of text providing help on how and when to use the function. If formatted properly, the MATLAB help function displays this text when you enter help functionname MATLAB considers the first group of consecutive lines immediately following the function definition line that begin with % to be the help section for the function. The first line without % as the left-most character ends the help.
For more information: See Help Text in the MATLAB Desktop Tools and Development Environment documentation.

Help for Subfunctions and Private Functions

You can write help for subfunctions using the same rules that apply to main functions. To display the help for the subfunction mysubfun in file myfun.m, type help myfun>mysubfun To display the help for a private function, precede the function name with private/. To get help on private function myprivfun, type help private/myprivfun

Help for Methods and Overloaded Functions

You can write help text for object-oriented class methods implemented with M-files. Display help for the method by typing help classname/methodname where the file methodname.m resides in subdirectory @classname. For example, if you write a plot method for a class named polynom, (where the plot method is defined in the file @polynom/plot.m), you can display this help by typing help polynom/plot You can get help on overloaded MATLAB functions in the same way. To display the help text for the eq function as implemented in matlab/iofun/@serial, type help serial/eq.


M-File Structure

An M-File consists of the components shown here:
function [x, y] = myfun(a, b, c)   % Function definition line
% H1 line -- A one-line summary of the function's purpose.
% Help text -- One or more lines of help text that explain
%   how to use the function. This text is displayed when
%   the user types "help functionname".

% The Function body normally starts after the first blank line.
% Comments -- Description (for internal use) of what the
%   function does, what inputs are expected, what outputs
%   are generated. Typing "help functionname" does not display 
%   this text.

x = prod(a, b);         
% Start of Function code
For more information: See Basic Parts of an M-File in the MATLAB Programming Fundamentals documentation.

Using Lowercase for Function Names

Function names appear in uppercase in MATLAB help text only to make the help easier to read. In practice, however, it is usually best to use lowercase when calling functions. For M-file functions, case requirements depend on the case sensitivity of the operating system you are using. As a rule, naming and calling functions using lowercase generally makes your M-files more portable from one operating system to another.
To obtain the name of an M-file that is currently being executed, use the following function in your M-file code.
mfilename
To include the path along with the M-file name, use
mfilename('fullpath')
For more information: See the mfilename function reference page.
For a simple display of all M-files referenced by a particular function, follow the steps below:
  1. Type clear functions to clear all functions from memory (see Note below).
  2. Execute the function you want to check. Note that the function arguments you choose to use in this step are important, since you can get different results when calling the same function with different arguments.
  3. Type inmem to display all M-Files that were used when the function ran. If you want to see what MEX-files were used as well, specify an additional output, as shown here:
       [mfiles, mexfiles] = inmem
    Note   clear functions does not clear functions locked by mlock. If you have locked functions, (which you can check using inmem), unlock them with munlock, and then repeat step 1.
For a much more detailed display of dependent function information, use the depfun function. In addition to M-files, depfun shows which built-ins and classes a particular function depends on.


Getting the Input and Output Arguments

Use nargin and nargout to determine the number of input and output arguments in a particular function call. Use nargchk and nargoutchk to verify that your function is called with the required number of input and output arguments.
function [x, y] = myplot(a, b, c, d)
disp(nargchk(2, 4, nargin))           % Allow 2 to 4 inputs
disp(nargoutchk(0, 2, nargout))       % Allow 0 to 2 outputs

x = plot(a, b);
if nargin == 4
   y = myfun(c, d);
end

Variable Numbers of Arguments

You can call functions with fewer input and output arguments than you have specified in the function definition, but not more. If you want to call a function with a variable number of arguments, use the varargin and varargout function parameters in the function definition. This function returns the size vector and, optionally, individual dimensions:
function [s, varargout] = mysize(x)
nout = max(nargout, 1) - 1;
s = size(x);
for k = 1:nout
   varargout(k) = {s(k)};
end
Try calling it with
[s, rows, cols] = mysize(rand(4, 5))
If you are passing only string arguments into a function, you can use MATLAB command syntax. All arguments entered in command syntax are interpreted as strings. strcmp string1 string1
ans =
     1
When passing numeric arguments, it is best to use function syntax unless you want the number passed as a string. The right-hand example below passes the number 75 as the string, '75'.
isnumeric(75)                   isnumeric 75
ans =                           ans =
    1                               0
For more information: See Command vs. Function Syntax in the MATLAB Programming Fundamentals documentation.

Passing Arguments in a Structure

Instead of requiring an additional argument for every value you want to pass in a function call, you can package them in a MATLAB structure and pass the structure. Make each input you want to pass a separate field in the structure argument, using descriptive names for the fields. Structures allow you to change the number, contents, or order of the arguments without having to modify the function. They can also be useful when you have a number of functions that need similar information.

Passing Arguments in a Cell Array

You can also group arguments into cell arrays. The disadvantage over structures is that you do not have field names to describe each variable. The advantage is that cell arrays are referenced by index, allowing you to loop through a cell array and access each argument passed in or out of the function.


Planning the Program

When planning how to write a program, take the problem you are trying to solve and break it down into a series of smaller, independent tasks. Implement each task as a separate function. Try to keep functions fairly short, each having a single purpose.
You may find it helpful to write the initial draft of your program in a structured format using your own natural language. This pseudo-code is often easier to think through, review, and modify than using a formal programming language, yet it is easily translated into a programming language in the next stage of development.

Selecting the Right Data Structures

Look at what classes and data structures are available to you in MATLAB and determine which of those best fit your needs in storing and passing your data.
For more information: see Classes (Data Types) in the Programming Fundamentals documentation.

General Coding Practices

A few suggested programming practices:
  • Use descriptive function and variable names to make your code easier to understand.
  • Order subfunctions alphabetically in an M-file to make them easier to find.
  • Precede each subfunction with a block of help text describing what that subfunction does. This not only explains the subfunctions, but also helps to visually separate them.
  • Do not extend lines of code beyond the 80th column. Otherwise, it will be hard to read when you print it out.
  • Use full Handle Graphics property and value names. Abbreviated names are often allowed, but can make your code unreadable. They also could be incompatible in future releases of MATLAB.

Naming a Function Uniquely

To avoid choosing a name for a new function that might conflict with a name already in use, check for any occurrences of the name using this command:
which -all functionname
For more information: See the which function reference page.
Be sure to document your programs well to make it easier for you or someone else to maintain them. Add comments generously, explaining each major section and any smaller segments of code that are not obvious. You can add a block of comments as shown here.
%---------------------------------------------
% This function computes the ... <and so on>
%---------------------------------------------
For more information: See Comments in the MATLAB Programming Fundamentals documentation.

Coding in Steps

Do not try to write the entire program all at once. Write a portion of it, and then test that piece out. When you have that part working the way you want, then write the next piece, and so on. It's much easier to find programming errors in a small piece of code than in a large program.

Making Modifications in Steps

When making modifications to a working program, do not make widespread changes all at one time. It's better to make a few small changes, test and debug, make a few more changes, and so on. Tracking down a difficult bug in the small section that you've changed is much easier than trying to find it in a huge block of new code.

Functions with One Calling Function

If you have a function that is called by only one other function, put it in the same M-file as the calling function, making it a subfunction. For more information: See Subfunctions in the MATLAB Programming Fundamentals documentation.
One suggested practice for testing a new program is to step through the program in the MATLAB debugger while keeping a record of each line that gets executed on a printed copy of the program. Use different combinations of inputs until you have observed that every line of code is executed at least once.



The MATLAB Debug Functions

For a brief description of the main debug functions in MATLAB, type help debug
For more information: See Debugging Process and Features in the MATLAB Desktop Tools and Development Environment documentation.
Other functions you may find useful in debugging are listed below.
FunctionDescription
echoDisplay function or script code as it executes.
dispDisplay specified values or messages.
sprintf, fprintfDisplay formatted data of different types.
whosList variables in the workspace.
sizeShow array dimensions.
keyboardInterrupt program execution and allow input from keyboard.
returnResume execution following a keyboard interruption.
warningDisplay specified warning message.
MExceptionAccess information on the cause of an error.
lastwarnReturn warning message that was last issued.

Learn to use the MATLAB graphical debugger. You can view the function and its calling functions as you debug, set and clear breakpoints, single-step through the program, step into or over called functions, control visibility into all workspaces, and find and replace strings in your files. Start out by opening the file you want to debug using File > Open or the open function. Use the debugging functions available on the toolbar and pull-down menus to set breakpoints, run or step through the program, and examine variables.
For more information: See Debugging Process and Features in the MATLAB Desktop Tools and Development Environment documentation.
To see the value of a variable from the Editor/Debugger window, hold the mouse cursor over the variable name for a second or two. You will see the value of the selected variable displayed.

Setting Breakpoints from the Command Line

You can set breakpoints with dbstop in any of the following ways:
  • Break at a specific M-file line number.
  • Break at the beginning of a specific subfunction.
  • Break at the first executable line in an M-file.
  • Break when a warning, or error, is generated.
  • Break if any infinite or NaN values are encountered.
For more information: See Setting Breakpoints in the MATLAB Desktop Tools and Development Environment documentation.

Finding Line Numbers to Set Breakpoints

When debugging from the command line, a quick way to find line numbers for setting breakpoints is to use dbtype. The dbtype function displays all or part of an M-file, also numbering each line. To display delaunay.m, use dbtype delaunay
To display only lines 35 through 41, use dbtype delaunay 35:41

Stopping Execution on an Error or Warning

Use dbstop if error to stop program execution on any error and enter debug mode. Use dbstop if warning to stop execution on any warning and enter debug mode.
For more information: See Debugging Process and Features in the MATLAB Desktop Tools and Development Environment documentation.

Locating an Error from the Error Message

Click on the underlined text in an error message, and MATLAB opens the M-file being executed in its editor and places the cursor at the point of error.
For more information: See Finding Errors, Debugging, and Correcting M-Files in the MATLAB Desktop Tools and Development Environment documentation.
You can detect erroneous or unexpected behavior in your programs by inserting warning messages that MATLAB will display under the conditions you specify. See the section on Warning Control in the MATLAB Programming Fundamentals documentation to find out how to selectively enable warnings.
For more information: See the warning function reference page.

Making Code Execution Visible

An easy way to see the end result of a particular line of codeis to edit the program and temporarily remove the terminating semicolon from that line. Then, run your program and the evaluation of that statement is displayed on the screen.

For more information: See Finding Errors, Debugging, and Correcting M-Files in the MATLAB Desktop Tools and Development Environment documentation.
Scripts store their variables in a workspace that is shared with the caller of the script. So, when you debug a script from the command line, the script uses variables from the base workspace. To avoid errors caused by workspace sharing, type clear all before starting to debug your script to clear the base workspace.


Rules for Variable Names Although variable names can be of any length, MATLAB uses only the first N characters of the name, (where N is the number returned by the function namelengthmax), and ignores the rest. Hence, it is important to make each variable name unique in the first N characters to enable MATLAB to distinguish variables. Also note that variable names are case sensitive.

N = namelengthmax
N =
    63
For more information: See Naming Variables in the MATLAB Programming Fundamentals documentation.

Making Sure Variable Names Are Valid

Before using a new variable name, you can check to see if it is valid with the isvarname function. Note that isvarname does not consider names longer than namelengthmax characters to be valid.
For example, the following name cannot be used for a variable since it begins with a number.
isvarname 8thColumn
ans =
     0
For more information: See Naming Variables in the MATLAB Programming Fundamentals documentation.

Do Not Use Function Names for Variables

When naming a variable, make sure you are not using a name that is already used as a function name. If you do define a variable with a function name, you will not be able to call that function until you clear the variable from memory. (If it's a MATLAB built-in function, then you will still be able to call that function but you must do so using builtin.) To test whether a proposed variable name is already used as a function name, use which -all name For more information: See Potential Conflict with Function Names in the MATLAB Programming Fundamentals documentation.

Checking for Reserved Keywords

MATLAB reserves certain keywords for its own use and does not allow you to override them. Attempts to use these words may result in any one of a number of error messages, some of which are shown here: Error: Expected a variable, function, or constant, found "=". Error: "End of Input" expected, "case" found. Error: Missing operator, comma, or semicolon. Error: "identifier" expected, "=" found. Use the iskeyword function with no input arguments to list all reserved words.

Avoid Using i and j for Variables

MATLAB uses the characters i and j to represent imaginary units. Avoid using i and j for variable names if you intend to use them in complex arithmetic. If you want to create a complex number without using i and j, you can use the complex function.
MATLAB scripts store their variables in a workspace that is shared with the caller of the script. When called from the command line, they share the base workspace. When called from a function, they share that function's workspace. If you run a script that alters a variable that already exists in the caller's workspace, that variable is overwritten by the script. For more information: See M-File Scripts in the MATLAB Programming
Fundamentals documentation.
To get the equivalent of a static variable in MATLAB, use persistent. When you declare a variable to be persistent within a function, its value is retained in memory between calls to that function. Unlike global variables, persistent variables are known only to the function in which they are declared. For more information: See Persistent Variables in the MATLAB Programming Fundamentals documentation.
You can inadvertently clear persistent variables from memory by either modifying the function in which the variables are defined, or by clearing the function with one of the following commands: clear all clear functions Locking the M-file in memory with mlock prevents any persistent variables defined in the file from being reinitialized.
Use global variables sparingly. The global workspace is shared by all of your functions and also by your interactive MATLAB session. The more global variables you use, the greater the chances of unintentionally reusing a variable name, thus leaving yourself open to having those variables change in value unexpectedly. This can be a difficult bug to track down.
For more information: See Global Variables in the MATLAB Programming Fundamentals documentation.


Creating Strings with Concatenation

Strings are often created by concatenating smaller elements together (e.g., strings, values, etc.). Two common methods of concatenating are to use the MATLAB concatenation operator ([]) or the sprintf function. The second and third line below illustrate both of these methods. Both lines give the same result:
numChars = 28;
s = ['There are ' int2str(numChars) ' characters here']
s = sprintf('There are %d characters here', numChars)
For more information: See Creating Character Arrays and Converting from Numeric to String in the MATLAB Programming Fundamentals documentation.
When building strings with concatenation, sprintf is often preferable to [] because
  • It is easier to read, especially when forming complicated expressions
  • It gives you more control over the output format
  • It often executes more quickly
You can also concatenate using the strcat function, However, for simple concatenations, sprintf and [] are faster.
It is usually best to store an array of strings in a cell array instead of a character array, especially if the strings are of different lengths. Strings in a character array must be of equal length, which often requires padding the strings with blanks. This is not necessary when using a cell array of strings that has no such requirement.
The cellRecord below does not require padding the strings with spaces:
cellRecord = {'Allison Jones'; 'Development'; 'Phoenix'};
For more information: See Cell Arrays of Strings in the MATLAB Programming Fundamentals documentation.
You can convert between standard character arrays and cell arrays of strings using the cellstr and char functions:
charRecord = ['Allison Jones'; 'Development  '; ... 
              'Phoenix      '];
cellRecord = cellstr(charRecord);
Also, a number of the MATLAB string operations can be used with either character arrays, or cell arrays, or both:
cellRecord2 = {'Brian Lewis'; 'Development'; 'Albuquerque'};
strcmp(charRecord, cellRecord2)
ans =
     0
     1
     0
For more information: See Converting to a Cell Array of Strings and String Comparisons in the MATLAB Programming Fundamentals documentation.

Search and Replace Using Regular Expressions

Using regular expressions in MATLAB offers a very versatile way of searching for and replacing characters or phrases within a string. See the help on these functions for more information.
FunctionDescription
regexpMatch regular expression.
regexpiMatch regular expression, ignoring case.
regexprepReplace string using regular  expression.

For more information: See Regular Expressions in the MATLAB Programming Fundamentals documentation.


Find Alternatives to Using eval

While the eval function can provide a convenient solution to certain programming challenges, it is best to limit its use. The main reason is that code that uses eval is often difficult to read and hard to debug. A second reason is that eval statements cannot always be translated into C or C++ code by the MATLAB Compiler. If you are evaluating a function, it is more efficient to use feval than eval. The feval function is made specifically for this purpose and is optimized to provide better performance.
For more information: See MATLAB Technical Note 1103, "What Is the EVAL Function, When Should I Use It, and How Can I Avoid It?" at URL http://www.mathworks.com/support/tech-notes/1100/1103.html.

Assigning to a Series of Variables

One common pattern for creating variables is to use a variable name suffixed with a number (e.g., phase1, phase2, phase3, etc.). We recommend using a cell array to build this type of variable name series, as it makes code more readable and executes more quickly than some other methods. For example:
for k = 1:800
   phase{k} = expression;
end

Short-Circuit Logical Operators

MATLAB has logical AND and OR operators (&& and ||) that enable you to partially evaluate, or short-circuit, logical expressions. Short-circuit operators are useful when you want to evaluate a statement only when certain conditions are satisfied. In this example, MATLAB does not execute the function myfun unless its M-file exists on the current path.
comp = (exist('myfun.m') == 2) && (myfun(x) >= y) 
For more information:   See Short-Circuit Operators in the MATLAB Programming Fundamentals documentation.
You cannot change the value of the loop counter variable (e.g., the variable k in the example below) in the body of a for loop. For example, this loop executes just 10 times, even though k is set back to 1 on each iteration.
for k = 1:10
   fprintf('Pass %d\n', k)
   k = 1;
end
Although MATLAB does allow you to use a variable of the same name as the loop counter within a loop, this is not a recommended practice.


Precedence Rules

When MATLAB is given a name to interpret, it determines its usage by checking the name against each of the entities listed below, and in the order shown:
  1. Variable
  2. Subfunction
  3. Private function
  4. Class constructor
  5. Overloaded method
  6. M-file in the current directory
  7. M-file on the path, or MATLAB built-in function
If you have two or more M-files on the path that have the same name, MATLAB selects the function that has its M-file in the directory closest to the beginning of the path string.
For more information: See Function Precedence Order in the MATLAB Programming Fundamentals documentation.

File Precedence

If you refer to a file by its filename only (leaving out the file extension), and there is more than one file of this name in the directory, MATLAB selects the file to use according to the following precedence:
  1. MEX-file
  2. MDL-file (Simulink model)
  3. P-Code file
  4. M-file
For more information: See Multiple Implementation Types in the MATLAB Programming Fundamentals documentation.
To add a directory to the search path, use either of the following:
  • At the toolbar, select File > Set Path.
  • At the command line, use the addpath function.
You can also add a directory and all of its subdirectories in one operation by either of these means. To do this from the command line, use genpath together with addpath. The online help for the genpath function shows how to do this. This example adds /control and all of its subdirectories to the MATLAB path: addpath(genpath('K:/toolbox/control'))
For more information: See Search Path in the MATLAB Desktop Tools and Development Environment documentation.

Handles to Functions Not on the Path

You cannot create function handles to functions that are not on the MATLAB path. But you can achieve essentially the same thing by creating the handles through a script file placed in the same off-path directory as the functions. If you then run the script, using run path/script, you will have created the handles that you need.
For example,
  1. Create a script in this off-path directory that constructs function handles and assigns them to variables. That script might look something like this:
    File E:/testdir/createFhandles.m
       fhset = @setItems
       fhsort = @sortItems
       fhdel = @deleteItem
  2. Run the script from your current directory to create the function handles:
    run E:/testdir/createFhandles
  3. You can now execute one of the functions by means of its handle.
    fhset(item, value)

Making Toolbox File Changes Visible to MATLAB

Unlike functions in user-supplied directories, M-files (and MEX-files) in the matlabroot/toolbox directories are not time-stamp checked, so MATLAB does not automatically see changes to them. If you modify one of these files, and then rerun it, you may find that the behavior does not reflect the changes that you made. This is most likely because MATLAB is still using the previously loaded version of the file. To force MATLAB to reload a function from disk, you need to explicitly clear the function from memory using clear functionname. Note that there are rare cases where clear will not have the desired effect, (for example, if the file is locked, or if it is a class constructor and objects of the given class exist in memory).
Similarly, MATLAB does not automatically detect the presence of new files in matlabroot/toolbox directories. If you add (or remove) files from these directories, use rehash toolbox to force MATLAB to see your changes. Note that if you use the MATLAB Editor to create files, these steps are unnecessary, as the Editor automatically informs MATLAB of such changes.

Making Nontoolbox File Changes Visible to MATLAB

For M-files outside of the toolbox directories, MATLAB sees the changes made to these files by comparing timestamps and reloads any file that has changed the next time you execute the corresponding function. If MATLAB does not see the changes you make to one of these files, try clearing the old copy of the function from memory using clear functionname. You can verify that MATLAB has cleared the function using inmem to list all functions currently loaded into memory.

Change Notification on Windows

If MATLAB, running on Windows, is unable to see new files or changes you have made to an existing file, the problem may be related to operating system change notification handles.
Type the following for more information:
help changeNotification
help changeNotificationAdvanced


Program Control

Using break, continue, and return

It's easy to confuse the break, continue, and return functions as they are similar in some ways. Make sure you use these functions appropriately.
FunctionWhere to Use ItDescription
breakfor or while loopsExits the loop in which it appears. In nested loops, control passes to the next outer loop.
continuefor or while loopsSkips any remaining statements in the current loop. Control passes to next iteration of the same loop.
returnAnywhereImmediately exits the function in which it appears. Control passes to the caller of the function.

Using switch Versus if

It is possible, but usually not advantageous, to implement switch-case statements using if-elseif instead. See pros and cons in the table.
switch-case Statementsif-elseif Statements
Easier to read.Can be difficult to read.
Can compare strings of different lengths.You need strcmp to compare strings of different lengths.
Test for equality only.Test for equality or inequality.

A useful difference between switch-case statements in MATLAB and C is that you can specify string values in MATLAB case statements, which you cannot do in C.
switch(method)
   case 'linear'
      disp('Method is linear')
   case 'cubic'
      disp('Method is cubic')
end
You can test against more than one condition with switch. The first case below tests for either a linear or bilinear method by using a cell array in the case statement.
switch(method)
   case {'linear', 'bilinear'}
      disp('Method is linear or bilinear')
   case (<and so on>)
end

Implicit Break in switch-case

In C, if you do not end each case with a break statement, code execution falls through to the following case. In MATLAB, case statements do not fall through; only one case may execute. Using break within a case statement is not only unnecessary, it is also invalid and generates a warning. In this example, if result is 52, only the first disp statement
executes, even though the second is also a valid match:
switch(result)
   case 52
      disp('result is 52')
   case {52, 78}
      disp('result is 52 or 78')
end

Variable Scope in a switch

Since MATLAB executes only one case of any switch statement, variables defined within one case are not known in the other cases of that switch statement. The same holds true for if-elseif statements. In these examples, you get an error when choice equals 2, because x is undefined.
  -- SWITCH-CASE --                    -- IF-ELSEIF --
switch choice
   case 1                          if choice == 1
      x = -pi:0.01:pi;                x = -pi:0.01:pi;
   case 2                          elseif choice == 2
      plot(x, sin(x));                plot(x, sin(x));
end                                end
When you have statements in your code that could possibly generate unwanted results, put those statements into a try-catch block that will catch any errors and handle them appropriately.
The example below shows a try-catch block within a function that multiplies two matrices. If a statement in the try segment of the block fails, control passes to the catch segment. In this case, the catch statements check the error message that was issued (returned in MException object, err) and respond appropriately:
try
   X = A * B
catch err
   errmsg = err.message;
   if(strfind(errmsg, 'Inner matrix dimensions'))
      disp('** Wrong dimensions for matrix multiply')
end
For more information: See The try-catch Statement in the MATLAB Programming Fundamentals documentation.

Nested try-catch Blocks

You can also nest try-catch blocks, as shown here. You can use this to attempt to recover from an error caught in the first try section: try
   statement1                    % Try to execute statement1
catch
   try
      statement2                 % Attempt to recover from error
   catch
      disp 'Operation failed'    % Handle the error
   end
end

Forcing an Early Return from a Function

To force an early return from a function, place a return statement in the function at the point where you want to exit. For example,
if <done>
   return
end







Mark Zuckerberg

mark zuckerberg bio, mark zuckerberg biography, priscilla chan mark zuckerberg, mark zuckerberg and eduardo saverin, mark zuckerberg worth, mark zuckerberg interview, mark zuckerberg value, wiki mark zuckerberg, eduardo saverin mark zuckerberg, mark zuckerberg snl, mark zuckerberg social network, mark zuckerberg s, mark zuckerberg wiki, mark zuckerberg house, mark zuckerberg and priscilla chan, priscilla chan and mark zuckerberg, wikipedia mark zuckerberg, mark zuckerberg eduardo, mark zuckerberg home, eduardo saverin and mark zuckerberg, mark zuckerberg priscilla chan, mark zuckerberg eduardo saverin, net worth of mark zuckerberg
The founder of Facebook is a young American man who goes by the name Mark Zuckerberg. Well, that is his name. Whilst it is Zuckerberg who is generally considered the websites founder, he actually co-founded the site with his university classmates Dustin Moskovitz, Eduardo Saverin, and Chris Hughes. They were not just any old bunch of classmates of course, they were Harvard students. Zuckerberg was born in White Plains, New York, on May 14th 1985 - making him just 25 at the time of me writing this page. His current net worth is estimated at $2bn and Time Magazine named him one of The World's Most Influential People of 2008, ranking at 52nd out of 101 in the 'Scientists & Thinkers' category.



Mark Zuckerberg Biography

Zuckerberg was born in White Plains, New York, and raised in the village of Dobbs Ferry, also New York. He is said to have begun programming whilst still in middle school and enjoyed developing communication tools and games from an early age. He went on to study briefly at Ardsley High School, a public secondary school, before moving on to the independent Phillips Exeter Academy. It was whilst at Phillips Academy that Zuckerberg built several advanced programs. The first was a program to help the workers at his fathers employer to communicate, then came a version of the game Risk, and then a music player called Synapse which learnt the users listening habits using artificial intelligence. Synapse was so advanced that both Microsoft and AOL attempted to purchase the software and recruit Zuckerberg, offers which he subsequently rejected in favour of attending Harvard University.
It was from his dorm room at Harvard, on 4th February 2004, that Zuckerberg launched the first version of Facebook. It initially started as a Harvard only thing, but was so popular amongst the universities students that he soon made moves to spread Facebook to other schools, it was at this point that Zuckerberg brought roommate Dustin Moskovitz on board, and the two spread the site to five other universities including Stanford, Cornell and Yale. It was no time at all before the site was extended to almost every educational institute in the United States. Remember that Zuckerberg was just 19 in February 2004! Zuckerberg soon forgot about Harvard and moved to Palo Alto in California, with Moskovitz and some other friends, renting a small house which served as their home and office. Zuckerberg has never returned to Harvard, instead seeing his company to grow to what it is now - huge!
It was in September 2006 that Zuckerberg and pals rolled out the News Feed on the site, instantly creating controversy and attracting criticism for its stalkerish characteristics. Stalkerbook is still a tag which sticks now of course. It was in 2007 that the website would truly begin to create noise globally, when it launched a Facebook platform, effectively making the site open source (although with certain restrictions and pre-approval measures). Developers worldwide began building applications and it was just a matter of weeks before their were applications with over a million users, there are now some 800,000 developers worldwide building applications for Facebook. I know one of them actually, doesn't seem so special to be associated with him now!


Facebook Inc. sold a 1.6% stake in the business to Microsoft Corporation for some $240m in 2007, suggesting an overall site value of some $15bn, although the sites growth in the years since make it likely that the company is worth much more than that figure now, in December 2009 Facebook claimed that it had 350m users. A movie based on the lives of Zuckerberg and his associates, called 'The Social Network' is set for release at some stage in 2010.

Mark Zuckerberg Controversy

Zuckerberg has not reached the top without controversy, the most significant being doubts over the originality of the idea. Former Harvard classmates Cameron Winklevoss and Tyler Winklevoss claim that Zuckerberg stole their idea for a social networking site whilst he was employed by them to assist with the sites development, the site in question being connectu.com. They filed a lawsuit as early as 2004 but the case was dismissed in March 2007, although it was quickly refiled in Boston, eventually Facebook settled the case for $65m.

Saturday, October 8, 2011

Steve jobs

SUSPENSION SYSTEM IN AUTOMOBILES

Written By   T. SIVA KUMAR                                                                     Asst.proff: Sai Sakthi Engineering Colle...