필터 지우기
필터 지우기

How to improve rendering of the figure after big data display (plot3)

조회 수: 4 (최근 30일)
Kamil
Kamil 2018년 3월 22일
답변: Kamil 2018년 3월 23일
Hi,
I have rendering problem after plotting multiple plot3 within for loop. I would like to post-process gcode data and plot it using plot3. However, as it has many points and layers(slice), I need to do it in for loop unless somebody knows better way. In addition, I do not want to plot one slice in once as it has movement included as well and I do not want to visualise it. Therefore I need to cut points from layers to smaller arrays. It gives even more plot within for loop. Afterwords, it takes ages to rotate...even with my Nvidia Quadro M4000. Any idea how it is possible to improve rendering of the plot? Can I for example create a big matrix with smaller matrices inside, different dimensions and then plot all in once (cell function?)? Once again I do not want to have connection between matrices. Anyway, will it helps plotting it once all or it does not change anything? Thanks for any advice.
  댓글 수: 1
Jan
Jan 2018년 3월 22일
Without seeing the code it is hard to guess, what you are doing exactly. It is useful to mention absolute numbers instead of the vague term "many". Maybe you mean 100, or a million. I do not know why it matters, that you use a for loop and how plot3 creates "layers(slices)". You can draw points without a connection for an array input also, but you did not explain how the output should look like. It is not clear what a "connection between matrices" is.
Please edit the question and post more details: Code, screen shots, absolute numbers and timings.

댓글을 달려면 로그인하십시오.

답변 (2개)

Kamil
Kamil 2018년 3월 23일
편집: Kamil 2018년 3월 23일
Hi again,
Thanks for response.
It is difficult to say number because it depends on the model. This one has 188 layers. Below will find the code. I know that it is still messy but the most problem I have with plot3 and visualisation.
I put two outputs. First is with movements that I want to avoid and second without them. The second is my goal. This is only one layer. I have like 188 as I mentioned above.
Thanks for any ideas.
name='C:\222cce167bc24a5d.gcode';
% read lines of the gcode fid = fopen(name); tline = fgetl(fid); A(1)=cellstr(tline); fclose(fid);
index1 = find(cellfun('length',regexp(A,';LAYER')) == 1); % read and save layers
for iL = 2:length(index1)
% read lines between task such as print inner wall, outer wall etc.
index = find(cellfun('length',regexp(A(index1(iL-1):index1(iL)),';')) == 1);
B = A(index1(iL-1):index1(iL)); % Read line in once
xk = zeros(25,5);
yk = zeros(25,5);
k=1;
n=1;
for ik = 3:length(index)
for in=index(ik-1)-1:index(ik)-1
GG=char(B(in)); % Read lines of code
indexE = strfind(GG,'E'); % find extrusion
indexX = strfind(GG,'X'); % fnd X values points
indexY = strfind(GG,'Y'); % find Y values points
indexG0 = strfind(GG, 'G0'); % find G0 values points
Eempty = isempty(indexE);
Xempty = isempty(indexX);
GOempty = isempty(indexG0);
if Xempty == 0
if GOempty == 0 % I need only G1
n=n+1;
k=1;
xk(k,n)=str2num(GG(indexX+1:indexY-1)); % get x values
yk(k,n)=str2num(GG(indexY+1:indexY+6)); % get y values
else
xk(k,n)=str2num(GG(indexX+1:indexY-1)); % get x values
yk(k,n)=str2num(GG(indexY+1:indexY+6)); % get y values
end
k=k+1;
end
end
if n == 1
else
for i = 1:n
ck = xk(:,i);
ck(ck==0) = []; % exclude zero values
cy = yk(:,i);
cy(cy==0) = []; % exclude zero values
z(1:length(ck))=Z(iL-1); % z values
em=isempty(ck);
if em == 1
else
plot3(ck,cy,z) % plot
hold on
end
z=0;
end
n=1;
k=1;
clear xk yk
end
end
end

Kamil
Kamil 2018년 3월 23일
It seems that putting a 'nan' value between points does the job. I will keep testing it. It speed up the visualisation. I will try to change the code to do it all layers in once and plot it as one big matrix. I hope it will work.

카테고리

Help CenterFile Exchange에서 Graphics Performance에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by