Clear Filters
Clear Filters

Defining a symbolic function in which one of the arguments is used to look up an entry of a vector, which is then used in the function.

2 views (last 30 days)
I have defined several numbers and a vector as follows:
d1=-0.3;d2=0.4;
dv=[d1 d2];
I now attempt to define a function in which one of the arguments of the function is used to look up an entry of the vector dv; and the selected entry of the vector is then used in the function. I have defined this function as follows:
syms y z
THETA(y, z) = dv(y) + z
I then want to use the function in a for loop (:
for j=1:MB;
Nzero(j, a)=sqrt((1/conj(a) - dv(j))*(THETA(l, a) - dv(j))/((a - dv(j))*(THETA(l, 1/conj(a)) - dv(j))));
end;
The issue that I am having is that MATLAB halts at
THETA(y, z) = dv(y) + z
Have I defined this function in an appropriate way for my use? In particular, I think the problem is with the use of the object dv(y) in this function. Is there a better way to code for one of the function's arguments to be used to look up an entry of a vector, which is subsequently used in the function?

Accepted Answer

Star Strider
Star Strider on 20 Jul 2016
If your question is about your ‘THETA’ function, it would be best for numerical results (not symbolic) to use an anonymous function:
THETA = @(y, z) dv(y) + z;
I cannot run your code, but that form of the function should do what you want.

More Answers (0)

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!