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 次查看(过去 30 天)
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?

采纳的回答

Star Strider
Star Strider 2016-7-20
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.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Number Theory 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by