How to complete this matrix?
Show older comments
- Use the meshgrid function with the following data: -8: 0.5: 8
- Use the following equation: R=x2+y2 treat x and y as vectors
- Use the Z=sin RR
- Hint: you will need the following: Z(R==0)=1
- Use the mesh function for you variables
10 Comments
Rik
on 23 Oct 2019
This is your homework. What have you tried so far?
Briana Pass
on 23 Oct 2019
Guillaume
on 23 Oct 2019
Reusing the same variable name (x) for two different purpose is not a good idea. There's no limitation to the number of variables you can have.
You seem to have done step 1) and 2) and skipped 3) and 4). What's preventing you from doing these (other than them being very unclear as you've written them)?
Briana Pass
on 23 Oct 2019
Cyrus Tirband
on 23 Oct 2019
What is the error you get? Can you format your code using the code blocks in the comments? It looks like you have the right answer, but it's hard to tell because of the awful typesetting. Are you using the pointwise division operator (./) to calculate Z?
Guillaume
on 23 Oct 2019
In which line should I change X
Whichever you want, but it makes more sense to keep the output of meshgrid as x, since that's what your assignment use. The first x which serves a completely different purpose could be renamed to gridspacing or something similar.
Briana Pass
on 23 Oct 2019
Cyrus Tirband
on 23 Oct 2019
The assignment is asking you to plot z = sin (R)/R, you're plotting x*exp(R).
If you define Z like was asked, you'll have to account for the location where R = 0 (given the snippet you were given) because matlab will naïvely divide zero by zero and give you NaN or Inf. You can then plot Z with the surf command. You'll get something like this

Guillaume
on 23 Oct 2019
matlab will naïvely divide zero by zero and give you NaN or Inf
There is nothing naive about it. dividing zero by zero is mathematically undefined. Matlab will give you NaN (not a number) if you still do it, never Inf for that.
The function
is undefined at 0. You can define a new function that is:
is undefined at 0. You can define a new function that is:

which is what seems to be asked here.
Briana Pass
on 23 Oct 2019
Answers (0)
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!