Error in variables statements, MATLAB Programming

Error in variables statements:

Error: The expression in the left of equals sign is not a valid target for an assignment.


By placing a semicolon at the end of the statement suppress the output. For illustration,

>> res = 9 - 2;


This would assign the result of the expression on the right side, the value 7, to the variable res; it merely doesn't show that result. Rather than, the other prompt appears instantly. Though, at this point in the Workspace Window the variables mynum and res can be seen.

The spaces in an expression or statement do not influence the result, but make it easier to read. The below statement that has no spaces would accomplish exactly the similar thing as the earlier statement:

>> res = 9-2;

The MATLAB uses a default variable named 'ans' if an expression is typed at the prompt and it is not assigned to a variable. For illustration, the result of the expression 6 + 3 is stored in the variable ans:

>> 6 + 3

ans =


This default variable is reused any time merely an expression is typed at the prompt. A short cut for retyping a command is to press the up-arrow ↑, which will go back to the formerly typed command. For illustration, if you decided to assign the result of the expression 6+3 to the variable res rather than of using the default ans, you can press the up-arrow and then the left-arrow to change the command rather than retyping the entire statement:

>> res = 6 + 3

res = 9


Posted Date: 10/18/2012 3:25:09 AM | Location : United States

Related Discussions:- Error in variables statements, Assignment Help, Ask Question on Error in variables statements, Get Answer, Expert's Help, Error in variables statements Discussions

Write discussion on Error in variables statements
Your posts are moderated
Related Questions
Water flow varies with water pressure. Two studies were made and two equations were developed: Parabolic fit:  F = 59.60180 + 3.77965 P - 0.01536 P 2       P

Implement a MatLab function to calculate y.  The function should take two input arguments 1) A vector of parameters In the above example this would be of length 3, the first

1) Convert the table into format convenient for the processing with MATLAB. 2) Prepare a program that perform K Nearest Neighbours algorithm using Euclidian distance. (Your prog

1. Given these sinusoids: x 1 (t) = 0.5cos(25t+20°),   x 2 (t)=0.85cos(25t+160°) and   x 3 (t)= 0.81cos(25t-145°) (a)  Subplot the phasors X 1 , X 2 and X 3 corresponding t

Generates sin or cos wave using plot functions: The script generates an x vector; iterating through all the values from 0 to 2*π in steps of 2*π /40 gives sufficient points to

Make a vector of 500 random numbers from a normal distribution with mean 2 and standard deviation 5(randn). a After you generate the vector, verify that the sample mean and stan

how to write the national log (ln(x)) in matlap ?

The fuel consumption of a certain make of car may not be exactly that rated by the manufacturer. Suppose ten cars of the same model were tested for combined city and highway fuel c

An electric overhead traveling crane, consisting of a girder, trolley, and wire rope, is shown in figure. The girder has a flexural rigidity (EI) of 6x10 12 2 and a span (L

Objectives In the following exercises, students are required ?rstly to implement code to determine the frequency components present in a signal, and then to extract a desired si