Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
plot3 slow

Subject: plot3 slow

From: pink

Date: 8 Jun, 2011 17:10:19

Message: 1 of 7

I create plot3 in gui axes, if the number of elements that the many depictions of the process is very slow, if you can provide solutions

for i=1:length(AX(:,1))
     plot3(AX(i,:),AZ(i,:),AY(i,:),'-c','LineWidth',0.25);
     hold on
     plot3(AXD(i,:),AZD(i,:),AYD(i,:),'-g','LineWidth',0.5);
end

Subject: plot3 slow

From: Steven_Lord

Date: 8 Jun, 2011 17:40:57

Message: 2 of 7



"pink " <wahyoe_slipnot@yahoo.co.id> wrote in message
news:isoadr$lts$1@newscl01ah.mathworks.com...
> I create plot3 in gui axes, if the number of elements that the many
> depictions of the process is very slow, if you can provide solutions
>
> for i=1:length(AX(:,1))
> plot3(AX(i,:),AZ(i,:),AY(i,:),'-c','LineWidth',0.25);
> hold on
> plot3(AXD(i,:),AZD(i,:),AYD(i,:),'-g','LineWidth',0.5); end

Each iteration through the loop is adding two more objects to the axes. Do
you really need 2*length(AX(:, 1)) lines on your axes all at once? If not,
either turn HOLD ON at the beginning of your loop and HOLD OFF at the end or
create the two lines before the FOR statement and use SET to update their
handles with the new XData, YData, and ZData during each iteration.

--
Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Subject: plot3 slow

From: pink

Date: 8 Jun, 2011 21:17:23

Message: 3 of 7

"Steven_Lord" <slord@mathworks.com> wrote in message <isoc79$rj9$1@newscl01ah.mathworks.com>...
>
>
> "pink " <wahyoe_slipnot@yahoo.co.id> wrote in message
> news:isoadr$lts$1@newscl01ah.mathworks.com...
> > I create plot3 in gui axes, if the number of elements that the many
> > depictions of the process is very slow, if you can provide solutions
> >
> > for i=1:length(AX(:,1))
> > plot3(AX(i,:),AZ(i,:),AY(i,:),'-c','LineWidth',0.25);
> > hold on
> > plot3(AXD(i,:),AZD(i,:),AYD(i,:),'-g','LineWidth',0.5); end
>
> Each iteration through the loop is adding two more objects to the axes. Do
> you really need 2*length(AX(:, 1)) lines on your axes all at once? If not,
> either turn HOLD ON at the beginning of your loop and HOLD OFF at the end or
> create the two lines before the FOR statement and use SET to update their
> handles with the new XData, YData, and ZData during each iteration.
>
> --

> Steve Lord
> slord@mathworks.com
> To contact Technical Support use the Contact Us link on
> http://www.mathworks.com

I've never tried to replace plot3 with the line, but the result is "error"
hold on
for i=1:length(AX(:,1))
plot3(AX(i,:),AZ(i,:),AY(i,:),'-c','LineWidth',0.25);
plot3(AXD(i,:),AZD(i,:),AYD(i,:),'-g','LineWidth',0.5); end
hold off
Is this correct?
on "axes (handles.axes1)" there is a underline which states like this
"calling AXES(h) whithout an output can be slow. Include 'h' in plot fucntion argument"

Subject: plot3 slow

From: Steven_Lord

Date: 9 Jun, 2011 13:59:07

Message: 4 of 7



"pink " <wahyoe_slipnot@yahoo.co.id> wrote in message
news:isoot3$6pg$1@newscl01ah.mathworks.com...
> "Steven_Lord" <slord@mathworks.com> wrote in message
> <isoc79$rj9$1@newscl01ah.mathworks.com>...
>>
>>
>> "pink " <wahyoe_slipnot@yahoo.co.id> wrote in message
>> news:isoadr$lts$1@newscl01ah.mathworks.com...
>> > I create plot3 in gui axes, if the number of elements that the many
>> > depictions of the process is very slow, if you can provide solutions
>> >
>> > for i=1:length(AX(:,1))
>> > plot3(AX(i,:),AZ(i,:),AY(i,:),'-c','LineWidth',0.25);
>> > hold on
>> > plot3(AXD(i,:),AZD(i,:),AYD(i,:),'-g','LineWidth',0.5); end
>>
>> Each iteration through the loop is adding two more objects to the axes.
>> Do you really need 2*length(AX(:, 1)) lines on your axes all at once? If
>> not, either turn HOLD ON at the beginning of your loop and HOLD OFF at
>> the end or create the two lines before the FOR statement and use SET to
>> update their handles with the new XData, YData, and ZData during each
>> iteration.
>>
>> --
>
>> Steve Lord
>> slord@mathworks.com
>> To contact Technical Support use the Contact Us link on
>> http://www.mathworks.com
>
> I've never tried to replace plot3 with the line, but the result is "error"
> hold on
> for i=1:length(AX(:,1))
> plot3(AX(i,:),AZ(i,:),AY(i,:),'-c','LineWidth',0.25);
> plot3(AXD(i,:),AZD(i,:),AYD(i,:),'-g','LineWidth',0.5); end
> hold off
> Is this correct?
> on "axes (handles.axes1)" there is a underline which states like this
> "calling AXES(h) whithout an output can be slow. Include 'h' in plot
> fucntion argument"

Let's take a step back.

When you're finished creating this plot, do you want to have 2*length(AX(:,
1)) lines on it all at once, do you want it to have two lines, or are you
looking for some other behavior (and if so, describe the behavior you want.)

--
Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Subject: plot3 slow

From: pink

Date: 9 Jun, 2011 16:48:05

Message: 5 of 7

"Steven_Lord" <slord@mathworks.com> wrote in message <isqjjb$24p$1@newscl01ah.mathworks.com>...
>
>
> "pink " <wahyoe_slipnot@yahoo.co.id> wrote in message
> news:isoot3$6pg$1@newscl01ah.mathworks.com...
> > "Steven_Lord" <slord@mathworks.com> wrote in message
> > <isoc79$rj9$1@newscl01ah.mathworks.com>...
> >>
> >>
> >> "pink " <wahyoe_slipnot@yahoo.co.id> wrote in message
> >> news:isoadr$lts$1@newscl01ah.mathworks.com...
> >> > I create plot3 in gui axes, if the number of elements that the many
> >> > depictions of the process is very slow, if you can provide solutions
> >> >
> >> > for i=1:length(AX(:,1))
> >> > plot3(AX(i,:),AZ(i,:),AY(i,:),'-c','LineWidth',0.25);
> >> > hold on
> >> > plot3(AXD(i,:),AZD(i,:),AYD(i,:),'-g','LineWidth',0.5); end
> >>
> >> Each iteration through the loop is adding two more objects to the axes.
> >> Do you really need 2*length(AX(:, 1)) lines on your axes all at once? If
> >> not, either turn HOLD ON at the beginning of your loop and HOLD OFF at
> >> the end or create the two lines before the FOR statement and use SET to
> >> update their handles with the new XData, YData, and ZData during each
> >> iteration.
> >>
> >> --
> >
> >> Steve Lord
> >> slord@mathworks.com
> >> To contact Technical Support use the Contact Us link on
> >> http://www.mathworks.com
> >
> > I've never tried to replace plot3 with the line, but the result is "error"
> > hold on
> > for i=1:length(AX(:,1))
> > plot3(AX(i,:),AZ(i,:),AY(i,:),'-c','LineWidth',0.25);
> > plot3(AXD(i,:),AZD(i,:),AYD(i,:),'-g','LineWidth',0.5); end
> > hold off
> > Is this correct?
> > on "axes (handles.axes1)" there is a underline which states like this
> > "calling AXES(h) whithout an output can be slow. Include 'h' in plot
> > fucntion argument"
>
> Let's take a step back.
>
> When you're finished creating this plot, do you want to have 2*length(AX(:,
> 1)) lines on it all at once, do you want it to have two lines, or are you
> looking for some other behavior (and if so, describe the behavior you want.)
>
> --
> Steve Lord
> slord@mathworks.com
> To contact Technical Support use the Contact Us link on
> http://www.mathworks.com

Yes. if completed, there are two lines

Subject: plot3 slow

From: Steven_Lord

Date: 9 Jun, 2011 17:18:13

Message: 6 of 7



"pink " <wahyoe_slipnot@yahoo.co.id> wrote in message
news:isqtg5$2s9$1@newscl01ah.mathworks.com...
> "Steven_Lord" <slord@mathworks.com> wrote in message
> <isqjjb$24p$1@newscl01ah.mathworks.com>...

*snip*

> Yes. if completed, there are two lines

So do something like:


% Create the lines before the loop
% Create the first line with "dummy" data that will be overwritten
myLines(1) = plot3(NaN, NaN, NaN, '-c','LineWidth',0.25);
% So the second PLOT3 call doesn't clear the first line, turn hold on
hold on
% Create the second line
myLines(2) = plot3(NaN, NaN, NaN, '-g','LineWidth',0.5);
% From now on, we're not going to call any high-level plotting function
% So we can turn hold back off
hold off

% Perform the plotting
for k = 1:length(AX(:,1)) % I try to avoid using i as a loop variable
    % Update line 1 using SET
    set(myLines(1), 'XData', AX(k,:), 'YData', AZ(k,:), 'ZData', AY(k,:));
    % Update line 2 using SET
    set(myLines(2), 'XData', AXD(k,:), 'YData', AZD(k,:), 'ZData',
AYD(k,:));
    % Give MATLAB time to update the graph
    drawnow;
    % You could use pause(someNumberOfSeconds) instead of DRAWNOW if desired
end


See this section of the documentation for more information about this and
other animation techniques.

http://www.mathworks.com/help/techdoc/creating_plots/f10-1460.html

--
Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Subject: plot3 slow

From: pink

Date: 9 Jun, 2011 17:40:05

Message: 7 of 7

"Steven_Lord" <slord@mathworks.com> wrote in message <isqv8l$7vd$1@newscl01ah.mathworks.com>...
>
>
> "pink " <wahyoe_slipnot@yahoo.co.id> wrote in message
> news:isqtg5$2s9$1@newscl01ah.mathworks.com...
> > "Steven_Lord" <slord@mathworks.com> wrote in message
> > <isqjjb$24p$1@newscl01ah.mathworks.com>...
>
> *snip*
>
> > Yes. if completed, there are two lines
>
> So do something like:
>
>
> % Create the lines before the loop
> % Create the first line with "dummy" data that will be overwritten
> myLines(1) = plot3(NaN, NaN, NaN, '-c','LineWidth',0.25);
> % So the second PLOT3 call doesn't clear the first line, turn hold on
> hold on

thanks lord
> % Create the second line
> myLines(2) = plot3(NaN, NaN, NaN, '-g','LineWidth',0.5);
> % From now on, we're not going to call any high-level plotting function
> % So we can turn hold back off
> hold off
>
> % Perform the plotting
> for k = 1:length(AX(:,1)) % I try to avoid using i as a loop variable
> % Update line 1 using SET
> set(myLines(1), 'XData', AX(k,:), 'YData', AZ(k,:), 'ZData', AY(k,:));
> % Update line 2 using SET
> set(myLines(2), 'XData', AXD(k,:), 'YData', AZD(k,:), 'ZData',
> AYD(k,:));
> % Give MATLAB time to update the graph
> drawnow;
> % You could use pause(someNumberOfSeconds) instead of DRAWNOW if desired
> end
>
>
> See this section of the documentation for more information about this and
> other animation techniques.
>
> http://www.mathworks.com/help/techdoc/creating_plots/f10-1460.html
>
> --
> Steve Lord
> slord@mathworks.com
> To contact Technical Support use the Contact Us link on
> http://www.mathworks.com

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us