- #1

- 195

- 0

## Main Question or Discussion Point

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.

- MATLAB
- Thread starter jaejoon89
- Start date

- #1

- 195

- 0

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.

- #2

- 1,233

- 17

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
```

- #3

- 166

- 0

Code:

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

- #4

- 22

- 0

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.

- Last Post

- Replies
- 8

- Views
- 2K

- Last Post

- Replies
- 1

- Views
- 2K

- Last Post

- Replies
- 2

- Views
- 1K

- Last Post

- Replies
- 2

- Views
- 2K

- Last Post

- Replies
- 9

- Views
- 6K

- Last Post

- Replies
- 1

- Views
- 2K

- Last Post

- Replies
- 3

- Views
- 6K

- Last Post

- Replies
- 10

- Views
- 3K

- Last Post

- Replies
- 1

- Views
- 1K

- Last Post

- Replies
- 1

- Views
- 1K