fix the soulation pleaase
1 次查看(过去 30 天)
显示 更早的评论
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
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
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:
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!