English 中文(简体)
Matlab -- -- 无法从单元格转换为双倍
原标题:Matlab -- Conversion to double from cell is not possible
  • 时间:2012-05-23 13:30:46
  •  标签:
  • matlab
  • 3d

Can someone tell me why I am receiving this error -- ??? The following error occurred converting from cell to double: Error using ==> double Conversion to double from cell is not possible.

Error in ==> test at 18 CX(end+1,:) = temp(1);

这是代码:

file = fopen( C:Program Files (x86)Notepad++	estFile.txt ); % open text file

tline = fgetl(file); % read line by line and remove new line characters

%declare empty arrays
CX = [];
CY = [];
CZ = [];

while ischar(tline) % true if tline is a character array
    temp = textscan(fid, %*s%f%f%f , Delimiter , ,<> ); % loads the values from all rows with the specified format into the variable data

    CX(end+1,:) = temp(1);
    CY(end+1,:) = temp(2);
    CZ(end+1,:) = temp(3);

    tline = fgetl(file);
end

fclose(file); % close the file

plot3(CX, CY, CZ) % plot the data and label the axises
xlabel( x )
ylabel( y )
zlabel( z ) 
grid on
axis square
最佳回答

使用 < a href=> "http://www.mathworks.com/help/techdoc/ref/cell2mat.html" rel="nofollow" > cell2mat 将单元格阵列(什么是 textscan return)转换成数字阵列,您可以用其他数字阵列来使用数字阵列(在您的情况下,类似于附加到) 。

我也建议使用, 而不是你采用的分类方法:http://www.mathworks.com/help/techdoc/ref/ververtcat.html" rel=“nofollow”>vertcat :

CX = vertcat(CX, cell2mat(temp(1)));

或者,你可以将所有3个值一行一行地读取, 并编成N+3矩阵, 而不是... 很多选项。

问题回答

快速猜测:使用卷曲牙套有帮助吗?

CX(end+1,:) = temp{1}




相关问题
3D Engine for Driving Simulation [closed]

Is there any open-source 3D graphics and physics engine specialized in driving simulation? Something like a configurable game engine targeted at games that involve driving, or something more ...

How to rotate 3d object on Z axis only?

We used 3DTools (http://3dtools.codeplex.com) to draw a 3d line, it allows user rotate it by mouse. I have question, how to limit user can rotate it on Z axis only? or on X axis, Y axis only? <...

WPF 3d rotation animations

I have a few 3d rectangles on my screen that I want to pivot around the Y axis. I want to press down with the mouse, and rotate the 3d object to a max rotation, but when the user moves their mouse, ...

Java - Zoom / 3D Data Visualization Libraries

What are the best libraries/frameworks for doing 3D and/or Zoom interfaces in Java? I d like to be able to do some prototyping of creating new types of interfaces for navigating within data and ...

Using Unreal 3 Engine within a .NET application

Now that the Unreal Development Kit for Unreal 3 engine is free I am thinking about utilizing it for an appication. Do you think it is possible to emebedd a Unreal 3 powered 3D window into a .NET (WPF ...

WPF convert 2d mouse click into 3d space

I have several geometry meshes in my Viewport3D, these have bounds of (w:1800, h:500, d:25). When a user clicks in the middle of the mesh, I want the Point3D of (900, 500, 25)... How can I achieve ...

热门标签