-1
텍스트 파일에서 데이터를 읽고 MATLAB에서 3D 플롯을 수행하려고합니다. 현재 내가 얻는 것은 빈 플롯이므로 데이터가 올바르게 저장되지 않았거나 전혀 사용되지 않는다고 생각합니다. 또한, 나는 모든 벡터의 끝에 1.000000을 원하지 않으므로 어떻게 무시할 수 있습니까? 감사. 코드Matlab : 파일에서 데이터 저장
다음인용문
TechEdge4:<152.266724,173.189377,27.995975> 1.000000
<117.880638,156.116531,27.999983> 1.000000
<129.849899,59.195660,27.999983> 1.000000
<249.321121,60.605404,27.999983> 1.000000
<224.120361,139.072739,28.000668> 1.000000
<171.188950,143.490921,56.933430> 1.000000
<171.188950,143.490921,83.548088> 1.000000
<171.188950,143.490921,27.999985> 1.000000
됩니다 :
file = fopen('C:\Program Files (x86)\Notepad++\testFile.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(tline,'%n%n%n', 'delimiter',',');
% convert all the cell fields to a matrix
CX = vertcat(CX, cell2mat(temp));
CY = vertcat(CY, cell2mat(temp));
CZ = vertcat(CZ, cell2mat(temp));
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
방금 TechEdge4를 꺼내었지만 코드 줄을 추가하면이 오류가 나타났습니다. 셀이 아닌 배열 개체에서 셀 내용 참조. 44 ==> cell2mat의 오류 cellclass = class (c {1}); 16 ==> 테스트에서 오류가 발생했습니다. CZ = vertcat (CZ, cell2mat (temp)); –
CZ를 완전히 제거하십시오. – Ansari
그러면 Z가없는 3D 그래프를 어떻게 그립니까? –