pdeplot command error in Matlab higher version than R2009!

조회 수: 1 (최근 30일)
Hosein Motamedi
Hosein Motamedi 2017년 3월 8일
답변: Amir 2017년 8월 16일
I am trying to use pdeplot (p,e,t) command in MATLAB R2016a. I got following error while it is working in MATLAB 2009b?
Would you please help me out how I can fix this issue?
Index exceeds matrix dimensions.
Error in pdeplot (line 242)
T=sparse(t([1 4 2 5 3 6],:),t([4 2 5 3 6 1],:),1,np,np);
here is the data dimension:
e=[];p=[]_2*19831 and t=[]_3*39436.

답변 (2개)

Walter Roberson
Walter Roberson 2017년 3월 9일
You say that
t=[]_3*39436
If we are to understand that t is 3 x 39436, then
T=sparse(t([1 4 2 5 3 6],:),t([4 2 5 3 6 1],:),1,np,np);
This attempts to access up to row 6 out of the 3 rows, so that would be a problem.
Glancing at the code, I see that just above that point there is a test as to whether T has exactly 4 rows, with only rows 1, 2, and 3 being used in that case. I see that t appears to correspond to a triangulation . The documentation for pdeplot describes t as,
"Mesh triangles, specified as a 4-by-Nt matrix of triangles, where Nt is the number of triangles in the mesh."
In R2009b, pdeplot describes the t matrix as created by initmesh, and initmesh says,
"In the Triangle matrix t, the first three rows contain indices to the corner points, given in counter clockwise order, and the fourth row contains the subdomain number."
Therefore a 3 x something triangulation matrix was invalid in R2009b and is invalid now.
  댓글 수: 2
Hosein Motamedi
Hosein Motamedi 2017년 3월 9일
Many thanks for your reply. But in contrast what you said, for Matlab R2009b, I have not received any error. The code is working and I can plot the mesh with no issue. Do you have any idea I can fixed this issue for higher version. Since I import the mesh from another software, what modification I need to apply on pde file to make them work in MATLAB R2016a. Thank you.
Walter Roberson
Walter Roberson 2017년 3월 9일
If everything is in the same "domain" then I think you might be able to add a 4th row that is the constant 1

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


Amir
Amir 2017년 8월 16일
Walter's comment is correct. In fact, if you just add t(4,:) = 1.0 (only adding a fourth row to make the matrices of same size), it will again starts working.

카테고리

Help CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by