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

New to MATLAB?

Is there a way to plot to a file while in a parfor loop?

Asked by Mark

Mark (view profile)

on 27 Mar 2013
Accepted Answer by Jing

Jing (view profile)

Hello,

I have a MATLAB program I'm running in parallel. I understand that I can't use a worker process to plot to the screen. But, I'm curious, is it possible to use a worker process to plot directly to a file?

Thanks,

Mark

0 Comments

Mark

Mark (view profile)

Products

No products are associated with this question.

1 Answer

Answer by Jing

Jing (view profile)

on 28 Mar 2013
Edited by Jing

Jing (view profile)

on 28 Mar 2013
Accepted answer

You can plot in parfor, it's just you won't see it, but the handle is still there. Then you can use saveas to save it to a file.

    parfor i=1:5
        figure(i)
        plot(rand(i*10,1));
        saveas(gcf,['temp' num2str(i) '.jpg']);
    end

1 Comment

Mark

Mark (view profile)

on 28 Mar 2013

Thanks a lot, I'm surprised there is such a simple solution!

Jing

Jing (view profile)

Contact us