how to use command"matlabFunction" in loop and handle function in loop

조회 수: 2 (최근 30일)
syms x y
rr=[x^2+y^2,x^2+1,y^2+2,3*x^3;
y^7+2,x^2+y,x^4+y^7,2]
for i=1:8
f(i)=matlabFunction(rr(i))
ma(i)=dblquad(f(i),-1,1,-1,1)
end
Can anyone help!! i really need help!! Above is my code!! my aim is to double integral(dblquad) the code have error when i run it .can any help me to modify it!! rr is my assumption.ecactly rr is big so i use a small matrix to replace
  댓글 수: 2
tony kevine
tony kevine 2015년 4월 20일
i have another question. how to look up a command which version release?
Star Strider
Star Strider 2015년 4월 20일
Go to the MATLAB Index and search for the function. The approximate release when it first appeared is at the end of the documentation page for it. That is new with the documentation for the R2015a release that is the current online documentation.

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

채택된 답변

Star Strider
Star Strider 2015년 4월 17일
It’s best not to bother with the numeric integrations and just keep it symbolic:
syms x y
rr=[x^2+y^2,x^2+1,y^2+2,3*x^3;
y^7+2,x^2+y,x^4+y^7,2]
ma_x = int(rr, x, -1, 1);
ma = int(ma_x, y, -1, 1)
produces:
ma =
[ 8/3, 16/3, 28/3, 0]
[ 8, 4/3, 4/5, 8]
  댓글 수: 2
tony kevine
tony kevine 2015년 4월 17일
dear Star Strider.
above rr is sample matrix ,exactly my matrix is so big and it need to numerically method to solve it.thanks you answer my issue
Star Strider
Star Strider 2015년 4월 17일
My pleasure.
Have you tried this on your much larger matrix?
I attempted a number of numerical integration routines (including those available in R2015a, such as integral with the 'ArrayValued',1 option) and I could not get it to run without throwing an error.
The only other option I can think of is to integrate each element of your matrix separately, creating a separate anonymous function for each element.

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

추가 답변 (1개)

Sean de Wolski
Sean de Wolski 2015년 4월 17일
Use cells to store the function handles
syms x y
rr=[x^2+y^2,x^2+1,y^2+2,3*x^3;
y^7+2,x^2+y,x^4+y^7,2]
f = cell(8,1)
for i=1:8
f{i}=matlabFunction(rr(i))
ma(i)=dblquad(f{i},-1,1,-1,1)
end
This won't fix the fact that your functions need different inputs so you'll need to figure that out.
  댓글 수: 1
tony kevine
tony kevine 2015년 4월 17일
hi,why need more inputs.actualy my real matrix is so big .above is my assumption i just ran your code,and it occur error.can you explain again(i am asian so please use some simple words)

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

카테고리

Help CenterFile Exchange에서 Data Type Identification에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by