<div><br></div><div>Dear All,</div><div><br></div><div>I met a problem about using "load()" function in Matlab to read a m file which describes a PETSc Mat object by :</div><div>
<pre style="margin-top: 0px; margin-bottom: 0px;"><!--StartFragment--><span style=" color:#008000;">//Save</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">coeff_matrix</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">as</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">a</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">matlab</span><span style=" color:#c0c0c0;"> </span><span style=" color:#008000;">file</span></pre>
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#800080;">PetscViewer</span><span style=" color:#c0c0c0;"> </span>viewer;</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;">PetscViewerASCIIOpen(PETSC_COMM_WORLD,"CoeffMatrixFileName.m",&viewer);</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;">PetscViewerSetFormat(viewer,<span style=" color:#c0c0c0;"> </span><span style=" color:#800080;">PETSC_VIEWER_ASCII_MATLAB</span>);</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;">MatView(coeff_matrix,<span style=" color:#c0c0c0;"> </span>viewer);</pre>
<pre style="margin-top: 0px; margin-bottom: 0px;">PetscViewerDestroy(&viewer);<!--EndFragment--></pre><pre style="margin-top: 0px; margin-bottom: 0px;"><br></pre><pre style="margin-top: 0px; margin-bottom: 0px;">In Matlab, I used:</pre><pre style="margin-top: 0px; margin-bottom: 0px;">M=load("CoeffMatrixFileName.m") </pre><pre style="margin-top: 0px; margin-bottom: 0px;">and I got an error.</pre><pre style="margin-top: 0px; margin-bottom: 0px;">The error is:</pre><pre style="margin-top: 0px; margin-bottom: 0px;">???Error using ===> load</pre><pre style="margin-top: 0px; margin-bottom: 0px;">Number of columns on line 2 of ASCII file CoeffMatrixFileName.m must be the same as previous lines.</pre><pre style="margin-top: 0px; margin-bottom: 0px;"><br></pre><pre style="margin-top: 0px; margin-bottom: 0px;">Do you know how to deal with that error?</pre><pre style="margin-top: 0px; margin-bottom: 0px;"><span style="line-height: 1.5;">Or Do you think </span>there<span style="line-height: 1.5;"> is some a mistake in my output of PETSc Mat Obj with the PetscViewer?</span><span style="line-height: 1.5; font-family: Verdana;"> </span></pre><pre style="margin-top: 0px; margin-bottom: 0px;"><span style="line-height: 1.5; font-family: Verdana;"><br></span></pre><pre style="margin-top: 0px; margin-bottom: 0px;"><font face="Verdana">Thank you~</font></pre><pre style="margin-top: 0px; margin-bottom: 0px;"><font face="Verdana">:)</font></pre><pre style="margin-top: 0px; margin-bottom: 0px;"><font face="Verdana"><br></font></pre><pre style="margin-top: 0px; margin-bottom: 0px;"><font face="Verdana">Meng</font></pre><pre style="margin-top: 0px; margin-bottom: 0px;"><br></pre></div>