Plot a function of two variables?

I implemented a function of two variables in Matlab :
function X=mFunction(alpha,beta).
I want to see his graph for the alpha and beta values between 0 and 1. How should I proceed?
Thanks

답변 (1개)

dpb
dpb 2016년 7월 3일

0 개 추천

See example at
doc meshgrid

댓글 수: 4

when I type the following commands:
[X,Y] = meshgrid(0:.2:1, 0:.2:1);
surf(X,Y,mFunction(X,Y))
matlab gives me the following error :
In an assignment A(I) = B, the number of elements in B and I must be the same.
Error in mFunction (line 40)
L(i)=alpha.*MS3(i)+(1-alpha).*L(i-1);
dpb
dpb 2016년 7월 4일
Your function isn't written correctly, then. Use the debugger to see what's the mismatch in dimensions; it's not totally apparent as one would presume i is a loop index and so is a single integer value; if MS3 is an array it would also be a single value but if it happened to be a function it could return something other than. Or alpha could be the culprit...
Whatever it is, it looks like the LHS is a single value whereas the RHS isn't. But, not enough context for us to tell for certain who's to blame but looks like alpha is the likely suspect.
amine&&
amine&& 2016년 7월 4일
Thanks Walter for your help!

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Logical에 대해 자세히 알아보기

질문:

2016년 7월 3일

댓글:

2016년 7월 4일

Community Treasure Hunt

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

Start Hunting!

Translated by