필터 지우기
필터 지우기

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

조회 수: 2 (최근 30일)
Ezz El-din Abdullah
Ezz El-din Abdullah 2017년 3월 5일
댓글: Guillaume 2017년 3월 6일
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
Ezz El-din Abdullah 2017년 3월 6일
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