0
$\begingroup$

I have created a three dimensional array "data" in matlab by using the following commands :

data=100*ones(100,100,100);
data(10:20,10:20,10:20)=20;
data(80:90,80:90,80:90)=80;
save data;

As you can see, most of elements in "data" have the value 100, but there are two zones located at two corners with value 20 and 80 respectively. Then I created a graph to show these two zones. Using the "isosurface" function in matlab, I get the picture below enter image description here

Now I want to import the "data" into mma, and plot a similar graph in mma. I tried the following commands in mma but got some errors :enter image description here

what's the mistake ? how should i do?
thanks for reviewing the navie quetions : )

$\endgroup$
  • 1
    $\begingroup$ Have you seen this: mathematica.stackexchange.com/a/24478/5 $\endgroup$ – rm -rf Oct 27 '15 at 8:50
  • $\begingroup$ Please show precisely what you tried so far. I don't see any problems when importing a mat file generated this way. $\endgroup$ – Szabolcs Oct 27 '15 at 10:43
  • $\begingroup$ (Just use Import) $\endgroup$ – Szabolcs Oct 27 '15 at 10:51
  • $\begingroup$ It's a good idea to look at the structure of the expression that Import returns. What I get is a list containing a path (string) and a 3D array. I need to take the second element of the list to get the 3D array. From the error message in your post it looks like you have a list containing a single 3D array. Take the first element of the list. $\endgroup$ – Szabolcs Oct 28 '15 at 10:56
1
$\begingroup$

Your "data" has most values 100 with some 80s and some 20s, yet your imported array from data.mat is almost all 1's. Once you locate the correct data file, you can check that

Dimensions[a]
{1,100,100,100}

has the wrong format for 3D plotting. You can fix this with Flatten, and then:

ListPlot3D[Flatten[a, 1]]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.