# Evaluating Functions in MATLAB with x,y Range 1-1000

• MATLAB
• jaejoon89

#### jaejoon89

Using MATLAB, how do you evaluate a function at integer values, say 1 to 1000, of x and y? For simplicity, let's say the function is z = x + y.

Hello

Try a loop within a loop to go through all x values then all y values?

Code:
z = zeros(1000);
for x= 1:1000
for y = 1:1000
z(x,y) = x + y;
end
end

Code:
[x y] = meshgrid(1:1000);
z = x + y;

Hi
Can anyone help how to write the matrix
A=[ 2 1 0 0 0
0 2 1 0 0
1 0 2 1 0
0 1 0 2 1
0 0 1 0 2]
I need A with the above pattern of any dimension n and also a vector of the form
v=[3 3 4 4 4 4 ...4 3 3]^T where v can be of any dimension. I'll be grateful for your help.

## 1. What is the purpose of evaluating functions in MATLAB with an x,y range of 1-1000?

The purpose of evaluating functions in MATLAB with an x,y range of 1-1000 is to analyze the behavior of a function over a large range of input values. This can provide valuable insights and help in making decisions related to the function's use and optimization.

## 2. How do I specify the x,y range when evaluating a function in MATLAB?

To specify the x,y range when evaluating a function in MATLAB, you can use the colon operator ":". For example, if you want to evaluate the function for x values from 1 to 1000, you can use the syntax "x = 1:1000". This will create a vector with values from 1 to 1000 that can be used as input for the function.

## 3. Can I evaluate multiple functions at once with an x,y range of 1-1000 in MATLAB?

Yes, you can evaluate multiple functions at once with an x,y range of 1-1000 in MATLAB by using the element-wise operations. This allows you to perform operations on arrays of values, making it possible to evaluate multiple functions simultaneously.

## 4. How can I plot the results of evaluating a function in MATLAB with an x,y range of 1-1000?

To plot the results of evaluating a function in MATLAB with an x,y range of 1-1000, you can use the "plot" function. This will generate a line plot with the x values on the horizontal axis and the corresponding y values on the vertical axis. You can also customize the plot by adding labels, titles, and adjusting the axes.

## 5. Is it possible to evaluate functions with non-numeric inputs in MATLAB?

Yes, it is possible to evaluate functions with non-numeric inputs in MATLAB. This can be done by using symbolic variables and functions, which allow you to work with algebraic expressions and perform operations on them. This can be useful for evaluating functions that involve symbols or variables instead of fixed numbers.