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!