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.
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Robert Mason
am 20 Jul. 2016
Beantwortet: Star Strider
am 20 Jul. 2016
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?
0 Kommentare
Akzeptierte Antwort
Star Strider
am 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.
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Assumptions finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!