want to draw a graph of a derivative
1 次查看(过去 30 天)
显示 更早的评论
I have to create a figure like this picture. Given value is r=262pixel, Wmax=10.6pi, equation is dw/dx= (Wmax*2x/r^2)ln(x^2+y^2/r^2) , x and y are two variables, we cannot know their values. x and y are satisfied the following condition:
sqrt(x^2+y^2)<=r
i did code this one. but this isn't wronking. plz anyone help me , what is wrong in here. I will be greatful to you.
% parameters
rmax = 262;
Wmax= 10.6*pi;
% create values
x = -rmax:rmax;
y = x.';
rsq = (x.^2 + y.^2);
diff(w)./diff(x) =Wmax*(((2*x)/(rmax^2))*ln((rsq)/(rmax^2)));
% truncate background
mk = rsq > rmax^2;
diff(w)./diff(x)(mk) = 0;
% show result
imshow(diff(w)./diff(x),[])
0 个评论
采纳的回答
DGM
2022-5-25
Something like this:
% parameters
rmax = 262;
Wmax= 10.6*pi;
% create values
x = -rmax:rmax;
y = x.';
rsq = (x.^2 + y.^2);
w = (Wmax*2*x/rmax^2).*log((rsq+eps)/rmax^2);
% truncate background
mk = rsq > rmax^2;
w(mk) = 0;
% show result
imshow(w,[])
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!