clc
clear
format long
d = [0.05 0.025 0.0125 0.00625 0.003125];
syms x y
f= 10000.*exp(y)/(1+abs(x)./2) ;
I_t_x = int(f,x,-5,0);
I_t = double(int(I_t_x,y,-2,2))
for i = 1:length(d)
x = -5 : d(i) : 0 ;
y = -2 : d(i) : 2 ;
[X,Y] = meshgrid(x,y);
F = 10000*exp(y)/(1+abs(x)/2) ;
I = trapz(y,trapz(x,F,2))
end

댓글 수: 2

Jan
Jan 2021년 5월 25일
Please post code as text, because then it can be reused easily to write an answer.
Whenever you mention an error in the forum, post a complete copy of the message. Then the readers can concentrate on solving the problem, instead on investing time in guessing, what the error is. You do have this important information on the screen already, so sharing it is the way to go.
jeaho jang
jeaho jang 2021년 5월 25일
I fixed it.

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

 채택된 답변

Jan
Jan 2021년 5월 25일

0 개 추천

Which error message do you get?
This should fail, if x and y are symbolic variables:
[X,Y] = meshgrid(x,y);
And you do not use the output X and Y at all:
F = 10000*exp(y)/(1+abs(x)/2) ;
I = trapz(y,trapz(x,F,2))

댓글 수: 5

jeaho jang
jeaho jang 2021년 5월 25일
편집: jeaho jang 2021년 5월 25일
I want to solve this function with trapezoid rule.
-5 <= x <= 0
-2 <=y <= 2
how can i do?
del x and del y = 0.05 0.025 0.0125 0.00625 0.003125
Torsten
Torsten 2021년 5월 25일
편집: Torsten 2021년 5월 25일
In your code, use
F = 10000*exp(Y)./(1+abs(X)/2)
And save the integration results in a vector:
I(i) = trapz(y,trapz(x,F,2))
This modification will also result in an error.
clc
clear
format long
d = [0.05 0.025 0.0125 0.00625 0.003125];
syms x y
f= 10000.*exp(y)/(1+abs(x)./2) ;
I_t_x = int(f,x,-5,0);
I_t = double(int(I_t_x,y,-2,2))
for i = 1:length(d)
x = -5 : d(i) : 0 ;
y = -2 : d(i) : 2 ;
[X,Y] = meshgrid(x,y);
F = 10000*exp(Y)/(1+abs(X)/2);
I(i) = trapz(y,trapz(x,F,2))
end
Torsten
Torsten 2021년 5월 25일
In the definition of F, I wrote ./, not only /
jeaho jang
jeaho jang 2021년 5월 25일
편집: jeaho jang 2021년 5월 25일
Thank you torsten

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

추가 답변 (0개)

카테고리

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

질문:

2021년 5월 25일

편집:

2021년 5월 25일

Community Treasure Hunt

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

Start Hunting!

Translated by