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 8110331
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T01:42:53+00:00 2026-06-06T01:42:53+00:00

I am trying to visualize the data contained a 3D array in MATLAB. The

  • 0

I am trying to visualize the data contained a 3D array in MATLAB.

The array is has the dimension of 20*20*40 which all except some of the elements being zero.

I am looking for a way to plot these non-zero points in a scatter plot so that the non-zero points are connected to each other.

here is what I’ve done so far:

b=zeros(6,6,3);
a=[1 1 1;2 2 1;2 1 1;1 2 1;
1 1 2;1 2 2;2 1 2;2 2 2;
6 6 3;6 5 3;5 6 3;5 5 3;
6 6 2;6 5 2;5 6 2;5 5 2];
[r c]=size(a);
for i = 1:r
 b(a(i,c-2),a(i,c-1),a(i,c)) = 1;
end
[m n o]=size(b);
figure (1)
[x,y,z] = meshgrid(1:m,1:n,1:o);
scatter3(x(:),y(:),z(:),90,b(:),'filled')

So, what I am after is being able to connect each of the eight points two form to cubic lattices. Any thoughts is much appreciated.
enter image description here

EDIT:
Many thanks to all the experts who helped a lot. Now, I am facing another issue with memory.

The b matrix for my real case would be 1000*1000*2000 and I have the “a” matrix of the size 4,4700,000*3 . All the elements of “a” matrix are integer values.
Although I have up to 48GB of memory availabe. However, in the “for loop” above the program bounces back an “out of memory” error.

Any ideas to make this more memory efficient is greatly appreciated.

  • 1 1 Answer
  • 0 Views
  • 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-06-06T01:42:54+00:00Added an answer on June 6, 2026 at 1:42 am

    I thought I’d answer the follow-up to Amro’s answer, and show how you can automate the connection of edges along a cubic matrix. This answer is intended to be a supplement to Amro’s, and I would recommend incorporating it into that solution so it is easier to read for future viewers.

    This starts with idx from Amro’s solution, which contains the linear indices of the corners of the cubes. Below I’ve done it with only one cube so the matrices aren’t grossly large and we can see them here.

    >> idx' %# transposed to save space in the printed output
    ans =
     1     2     7     8    37    38    43    44 '
    
    %# now get the subindex of each point in 3D
    >> [sx sy sz] = ind2sub([6 6 3],idx);
    %# calculate the "edge distance" between each corner (not euclidean distance)
    >> dist = abs(bsxfun(@minus,sx,sx')) +...
              abs(bsxfun(@minus,sy,sy')) +...
              abs(bsxfun(@minus,sz,sz'))
    dist =
    
     0     1     1     2     1     2     2     3
     1     0     2     1     2     1     3     2
     1     2     0     1     2     3     1     2
     2     1     1     0     3     2     2     1
     1     2     2     3     0     1     1     2
     2     1     3     2     1     0     2     1
     2     3     1     2     1     2     0     1
     3     2     2     1     2     1     1     0 '
    
    %# find row and column index of points one edge apart
    >> [r c]=find(triu(dist==1)); %# triu means don't duplicate edges
    
    %# create 'p' matrix like in Amro's answer
    >> p = [idx(r) idx(c)]'
    p =
     1     1     2     7     1     2    37     7    37     8    38    43
     2     7     8     8    37    38    38    43    43    44    44    44
    

    To visualize, you can plot exactly like in Amro’s answer.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my WPF application im trying to visualize some temperature data. I have a
I'm trying to visualize some data I have stored on a regular grid using
I have a very large possible data set that I am trying to visualize
I have some data about a day's events that I'm trying to visualise as
I'm trying to visualize a numpy array using imshow() since it's similar to imagesc()
I am trying to gather data from twitter and visualize it through Graphviz. I
I am looking for a simple way to visualize some of my data in
I'm trying to use Google chart tools to visualize data on my site. The
I'm trying to visualize data like in this spreadsheet https://docs.google.com/spreadsheet/ccc?key=0AhtsNUEmDE6MdE0ybXppcG1jampsVnBfZWpEZm9vbmc . So I would
I'm trying to visualize a data on a grid with cell values actually represented

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.