How to pass values to a vector inside an anonymous function for ezplot?

2 次查看(过去 30 天)
I wonder how can I benefit from passing additional parameter for ezplot function.
I'm trying to plot implicit function that has a vector th inside which has the problem.
Here is the code:
delta = pi*[1 2 3];
m = 1:100;
th{1,1}(1:100) = 2*pi*m*delta(1);
th{2,1}(1:100) = 2*pi*m*delta(2);
th{3,1}(1:100) = 2*pi*m*delta(3);
myfun = @(x,y,k) x + y.*th{k,1}(1:100) + k;
for k = 1:3
ezplot(@(x,y)myfun(x,y,k));
hold on
end
  10 个评论
Ezz El-din Abdullah
What I mean by three lines is that the equation x + y*th + k is satisfied.
Let's consider the simplest case when th is a scalar. Since th has the vector delta which has three values in it. It will produce three lines. I know that the output of ezplot is just 1x1 so when th is a scalar the ezplot will not complain.
The problem comes when we consider the th as a vector like I wrote in the code.
So for each value of delta which corresponds to the first vector of the th 2D matrix (as you explained) I would like to "sort of" convert this vector into a just symbolic 1x1 that ezplot output can produce. So actually, I don't know what myfun(x,y,k) should produce.
It happens that for a scalar value of th it produced this figure:
For that case:
>> myfun(1,1,1)
ans =
2
I hope I'm clear now and thanks.
Guillaume
Guillaume 2017-3-6
I understand everything you wrote except the I would like to "sort of" convert this vector into a just symbolic 1x1 that ezplot output can produce. It doesn't sound that you actually know what you want.
ezplot plots where myfun(x, y) == 0. What does equal to 0 mean when myfun(x, y) is a vector of 100 values? Do you want the zeros of the function
f(x, y) = x + a*y + k
for 100 different scalar a and 3 different scalar k, resulting in 300 plots?

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Graphics Performance 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by