How to obtain a matrix element in a matrix defined by a function?
Show older comments
I have a function as shown below:
A(xi, eta) =
conj(eta)/24 - 1/24
conj(xi)/16 - 1/16
1/24 - conj(eta)/24
- conj(xi)/16 - 1/16
conj(eta)/24 + 1/24
conj(xi)/16 + 1/16
- conj(eta)/24 - 1/24
1/16 - conj(xi)/16
In this function, I want to obtain the 3rd element of matrix i.e 1/24 - conj(eta)/24 by using the function A(3,1) but on doing so, I am obtaining the value of function at xi=3 and eta=1. How can I get the third element or any required element of the matrix?
4 Comments
Stephen23
on 9 Sep 2018
"I have a function as shown below..:"
That is not a function:
It appears you have simply calculated some value/s, and allocate these to an array A.
"In this function, I want to obtain the 3rd element of matrix i.e 1/24 - conj(eta)/24 by using the function A(3,1)"
You don't have a function, just an array A. So A(3,1) is basic MATLAB indexing into an array:
It is not clear what you expect to happen, but it seems that you should actually spend some time learning basic MATLAB concepts, such as what functions are, what arrays are, how to use indexing, etc. Most of these basic concepts are introduced on the "Getting Started" tutorials:
Achyut Paudel
on 9 Sep 2018
Stephen23
on 9 Sep 2018
"On writing A(3,1), rather than getting 3rd element, I am getting all the arrays with the value of xi=3 and eta=1."
Then you will need to write a function. See the links I gave in my last comment.
Achyut Paudel
on 10 Sep 2018
Accepted Answer
More Answers (0)
Categories
Find more on Seismology 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!