Multiple plots for 100 separate data using for – loop

Home Forums Matlab Multiple plots for 100 separate data using for – loop

This topic contains 1 reply, has 2 voices, and was last updated by  cK 8 years, 11 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #581

    Greatness
    Participant

    I’m trying to make multiple scatter plots involving 100 data (200 by 1). These are to be plotted against just one data (200 by 1), and the whole idea is to check if the plots lie around the 45 degree line. But I realised that only 1 data is displayed in the plot, rather than 100. The code is seen below:

    N=100;
    for i = 1:N
    figure(1), plot(actual,pred(:,:,i),’or’,'MarkerSize’,15); hold on;
    xlim([0.05 0.70]);ylim([0.05 0.70]);
    line(xlim,ylim,’Color’,'k’);
    xlabel(‘Actual data’); ylabel(‘Predicted data’);
    hold off;
    end

    Please what could be the problem? I’ll appreciate your reply. Thank you.

    #582

    cK
    Keymaster

    Take figure(1) and hold on out of the loop (before the loop) and do not do hold off. But this would be slow and untidy way to do it. You should just be able to do scatter(x,y) where x is 200×1 vector y is 200×100 matrix and you would see 100 scatter plots. If y is nominally 3-dimensional but has unitary 1st or 2nd dimension, do squeeze(y).

    • This reply was modified 8 years, 11 months ago by  cK.
Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.