필터 지우기
필터 지우기

Elementwise multiplication, function definition

조회 수: 2 (최근 30일)
Ben
Ben 2013년 5월 17일
Hello Community
I have an issue defining a function where the input is a meshgrid. Somehow there must be an issue with the elementwise multiplication.
Input: [x, y] = meshgrid(linspace(0,400,400),linspace(0,30000,400));
A1 = -8.269000000000000;
m1 = 2.071000000000000;
m2 = 0.239700000000000;
B1 = -13.100000000000000;
n1 = 2.813000000000000;
B2 = -49.960000000000001;
n2 = 18.170000000000002;
z1 = (10^A1*x.^m1*y.^m2+y.*(10^B1*x.^n1+10^B2*x.^n2))*100;
Output:
min(min(z1)) = 188.7492
Conclusion:
The minimal value of z1 is 188.7492. However looking at the equation, z1 should be 0 for x = 0 and y = 0.
Somehow there is a mistake writing the equation oder defining input (x,y)
Can anybody help me?

채택된 답변

Iman Ansari
Iman Ansari 2013년 5월 17일
[x, y] = meshgrid(linspace(0,400,400),linspace(0,30000,400));
A1 = -8.269000000000000;
m1 = 2.071000000000000;
m2 = 0.239700000000000;
B1 = -13.100000000000000;
n1 = 2.813000000000000;
B2 = -49.960000000000001;
n2 = 18.170000000000002;
z1 = (10^A1*x.^m1.*y.^m2+y.*(10^B1*x.^n1+10^B2*x.^n2))*100;
min(min(z1))
  댓글 수: 1
Ben
Ben 2013년 5월 17일
Thank you! You must be a wizard! Have a nice day!

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

추가 답변 (1개)

David Sanchez
David Sanchez 2013년 5월 17일
Hi, try your code like this:
[x, y] = meshgrid( linspace(0,400,400),linspace(0,30000,400) );
A1 = -8.269000000000000;
m1 = 2.071000000000000;
m2 = 0.239700000000000;
B1 = -13.100000000000000;
n1 = 2.813000000000000;
B2 = -49.960000000000001;
n2 = 18.170000000000002;
AA = 10^A1;
BB = x.^m1;
CC = y.^m2;
z1_1 = AA.*BB.*CC;
DD = 10^B1;
EE = x.^n1;
FF = 10^B2;
GG = x.^n2;
z1_2 = y.*( DD*EE + FF*GG );
z1 = ( z1_1 + z1_2 )*100;
  댓글 수: 2
David Sanchez
David Sanchez 2013년 5월 17일
You will get you zero values along with values close to 0 too.
Ben
Ben 2013년 5월 17일
Thank you for spending time on my problem! The solution above works very fine an was what I was going for. Have a nice day!

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

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by