Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 644805
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T21:26:00+00:00 2026-05-13T21:26:00+00:00

I am trying to plot a series of 2D matrices containing ones and zeros

  • 0

I am trying to plot a series of 2D matrices containing ones and zeros (effectively black and white images) in MATLAB, which are ordered in 3D.

The code I have so far is:

function PlotthreeD()

 numrows = 100;
 numcols = 100;

 Plot1 = zeros(numcols);
 Plot1(20:50,20:50) = 1;

 Plot2 = zeros(numcols);
 Plot1(20:70,20:90) = 1;

 Plot3 = zeros(numcols);
 Plot3(20:50,20:50) = 1;

         B = cat(3, Plot1, Plot2, Plot3);

 figure; 
 offset = 100;
 hold on; 

 for i=1:3; 
     mesh(B(:,:,i)+offset*(i));
 end

end

Is there a drawing command (rather than mesh) that will allow me show the 2D arrays as solid shapes (where the matrix elements equal 1), rather than having a these regions shown as being raised (as they are with mesh)?

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T21:26:00+00:00Added an answer on May 13, 2026 at 9:26 pm

    This will do it:

    numrows = 100;
    numcols = 100;
    close all;
    
    Plot1 = zeros(numcols);
    Plot1(20:50,20:50) = 1;
    
    Plot2 = zeros(numcols);
    Plot2(20:70,20:90) = 1;
    
    Plot3 = zeros(numcols);
    Plot3(20:50,20:50) = 1;
    
    B = cat(3, Plot1, Plot2, Plot3);
    B(B==0)=NaN;
    
    figure;
    offset = 100;
    hold on;
    
    for i=1:3;
        surf(B(:,:,i)+offset*(i)); 
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to plot some one-dimensional data onto a 2-D plot in MATLAB.
I'm having a problem trying to plot a series of lines in a 3D
As I am trying to plot a few financial time series in Mathematica, I
I'm trying to understand how to have more than one series on a plot,
I am trying to do a scatter plot of 2 time series data -
I am trying to plot two data series in an MSChart. I am using
I'm trying to plot a series of rectangles and lines based on a tab
I am trying to plot two lines series on a chart. Each line with
I'm trying do define an interface in which I want to plot some values
The context is that I am trying to plot a series of temperatures as

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.