'Subscripted assignment dimension mismatch" error..can anyone help?

1 回表示 (過去 30 日間)
siddhesh rane
siddhesh rane 2013 年 5 月 21 日
I am writing a program to access elements in the cell and put them in mtrix and i m getting above error..my code is as follows..I have (1*1) cell with column matrix with k rows in it..
i want to access elements in column matrix in following sequence (11,12,13,15,16,17,19,20,21...)
function [ coordinates ] = readSTL1( filename,k)
% reads ASCII STL file and gives coordinates of vertices.
%filename-name of file(test.txt),k- number of rows in column matrix.
fid=fopen(filename);
C=textscan(fid,'%s');
%reads file and generates cell.
m = 1;
i = 1;
while(m < (k-3))
% m is row number of column matrix
l = 1;
while(l<4)
P(i,1) = C{1,1}{m,1}; % see help for accessing cell arrays
l = l+1; % makes sure loop runs thrice.
m = m+1; % access corresponding row from cell'C'.
i = i+1; % row number in output matrix.
end
m = m+1;
end
end
  1 件のコメント
Jan
Jan 2013 年 5 月 22 日
Please post the complete error message, most of all the detail in which line the error occurres. This would be much more efficient than letting us guess this detail.

サインインしてコメントする。

採用された回答

Walter Roberson
Walter Roberson 2013 年 5 月 22 日
You are trying to store an entire string (which is a vector of characters) into the single scalar location P(i,l)
What datatype are you expecting P to come out as? If you are expecting it to come out as a cell array of strings, then assign to P{i,1}
  1 件のコメント
siddhesh rane
siddhesh rane 2013 年 5 月 23 日
Thank you..i converted numerical strings in the cell into doubles..it worked.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCharacters and Strings についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by