Info

Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.

I am getting error while accessing data from cell and storing it in matrix..can anyone help?

3 Ansichten (letzte 30 Tage)
The following error occurred converting from cell to double:
Error using double
Conversion to double from cell is not possible.
Error in readSTL1 (line 17)
coordinates(i,1) = C{1,1}(m,1);

Antworten (1)

Azzi Abdelmalek
Azzi Abdelmalek am 21 Mai 2013
Bearbeitet: Azzi Abdelmalek am 21 Mai 2013
Clear your variable then try again
clear coordinates
  2 Kommentare
siddhesh rane
siddhesh rane am 21 Mai 2013
Bearbeitet: Azzi Abdelmalek am 21 Mai 2013
tried..still not working. My code is as follows
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 cell.
fid=fopen(filename);
C=textscan(fid,'%s');
%reads file and generates cell.
m = 11;
i = 1;
coordinates = zeros(4455,1);
while(m < (k-3))
j = 1;
while (j < 4)
l = 1;
while(l<4)
coordinates(i) = C{1,1}(m);
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;
j = j+1;
end
m = m+10;
end
end
Azzi Abdelmalek
Azzi Abdelmalek am 21 Mai 2013
Bearbeitet: Azzi Abdelmalek am 21 Mai 2013
Instead if
coordinates = zeros(4455,1);
Use
coordinates = num2cell(zeros(4455,1));
Or just change c{1,1}{m} instead of c{1,1}(m)
coordinates(i) = C{1,1}{m}

Diese Frage ist geschlossen.

Community Treasure Hunt

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

Start Hunting!

Translated by