fix the soulation pleaase

1 次查看(过去 30 天)
Yousif Hamzah
Yousif Hamzah 2019-9-9
Please any one can fix this for me please
>> [x,y]=meshgrid(-pi:0.1:pi,-pi:0.1:pi);
>> z=exp(-x.^2*y.^2).*sin(x*y);
>> mesh(x,y,z); axis image;
>> options= {,'interpreter','latex','fontSize',14}; % Use LATEX for labeling
>> xlabel('$x$-axis',options{:}); ylabel('$y$-axis',options{:});
>> title('ASCENT',options{:});
>> hold on
>> p=[-1.6,-1.6];
>> plot(p(1,1),p(1,2),'or','MarkerSize',10);
>> x=p(1,size(p,2));
>> y=p(2,size(p,2));
Index in position 1 exceeds array bounds (must not exceed 1).
>> y=p(1,size(p,2));
>> fx=-2*x*y^2*exp(-x^2*y^2)*sin(x*y);
>> fy= -2*x^2*y*exp(-x^2*y^2)*sin(x*y);
>> p=[p p(:,size(p,2))+0.2*[fx;fy]]; % the only line that really maters
Error using horzcat
Dimensions of arrays being concatenated are not consistent.
  1 个评论
Walter Roberson
Walter Roberson 2019-9-12
I already explained this to you.
You need to decide whether your y coordinates are to be stored in the second column of the variable, or in the second row of the variable.

请先登录,再进行评论。

回答(1 个)

Devineni Aslesha
Devineni Aslesha 2019-9-12
In the provided code, the size of p is 1x2. However, the size of p(:,size(p,2))+0.2*[fx;fy] is 2x1. While concatenating horizontally, all the arrays should have the same number of rows. So, it can be concatenated as shown below.
p = [p p(: , size(p,2))+0.2*[fx fy]];
Doc Link:

类别

Help CenterFile Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息

产品


版本

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by