0
$\begingroup$

Solving bending of a plate with a hole I came up with the problem of plotting empty matrix elements. I got results of deflection in matrix m (here is simplified code where m contains results of previous calculations, dx and dy are size of element in finite difference method used to calculate deflections):

dx = 20;
dy = 20;
m = {{-0.529905, -0.439313, -0.351192, -0.309829, -0.277381, \
-0.279626, -0.305599, -0.310473, -0.333545, -0.414396, -0.500825}, \
{-0.504563, -0.366099, -0.234522, -0.213233, -0.158445, -0.169855, \
-0.230793, -0.203875, -0.195498, -0.316359, -0.445873}, {-0.449676, \
-0.271052, 0, 0, 0, 0, 0, 0, 
    0, -0.180155, -0.336509}, {-0.386551, -0.22993, 0, 0, 0, 0, 0, 0, 
    0, -0.0506295, -0.164954}, {-0.247702, -0.0424227, 0, 0, 0, 0, 0, 
    0, 0, 0.450029, 0.191015}, {-0.0460756, 0.254853, 0, 0, 0, 0, 0, 
    0, 0, 1.11752, 0.648574}, {0.16454, 0.598028, 0, 0, 0, 0, 0, 0, 0,
     1.79007, 1.07852}, {0.284961, 0.848659, 0, 0, 0, 0, 0, 0, 0, 
    2.21468, 1.30024}, {0.182955, 0.637385, 0, 0, 0, 0, 0, 0, 0, 
    1.76687, 1.10412}, {-0.00309753, 0.348789, 0.751991, 1.14756, 
    1.11667, 1.73377, 1.72763, 2.34391, 1.83049, 1.29127, 
    0.792653}, {-0.193837, 0.0610459, 0.354048, 0.623964, 0.766462, 
    1.0777, 1.20698, 1.41556, 1.17983, 0.823121, 0.467826}};

I gave x and y positions to each value in matrix dataPoints and used ListPlot3D to plot results

dataPoints = 
  Table[{i*dx, j*dy, m[[i + 1, j + 1]]}, {i, 0, 9}, {j, 0, 9}];
ListPlot3D[Flatten[dataPoints, 1], 
 AxesLabel -> {Style[x, Medium, Blue], Style[y, Medium, Blue], 
   Style[u, Medium, Blue]}, 
 ColorFunction -> Function[{x, y, z}, Hue[z]], PlotRange -> All]

and when i use ListPlot3D i get this plot:

deflection

My goal is to print plot where should be hole in place where now zeros are but not defining plot depending on U value rather x and y. So basicly solutions should depend on x and y not u variable.

I have tried searching for similar problems but I don't know how i could implement exclusions in my problem.

Can this be done and how to solve this problem? Please help.

I have tried using RegionFunction but I am stuck and I don't know how to define region function so that middle area get removed. One answer suggested I use

RegionFunction -> Function[{x, y, z}, z != 0

But this is not satisfying as I need to exclude a surface inside but some edges or some other points can also have value 0.

$\endgroup$
1
$\begingroup$

Maybe with RegionFunction?

ListPlot3D[Flatten[dataPoints, 1], 
AxesLabel -> {Style[x, Medium, Blue], Style[y, Medium, Blue], 
Style[u, Medium, Blue]}, 
ColorFunction -> Function[{x, y, z}, Hue[z]], PlotRange -> All, 
RegionFunction -> Function[{x, y, z}, z != 0]]

enter image description here

$\endgroup$
  • $\begingroup$ This will also remove boundary elements that have also deflection 0 which I want to avoid. But RegionFunction might help me if i use it in different way. I'll try thanks $\endgroup$ – Katarina Dec 8 '17 at 15:52
  • $\begingroup$ But should not those elements appear also as $0$ in matrix m? You could add constraints in RegionFunction for $x$ and $y$ variables, I guess $\endgroup$ – José Antonio Díaz Navas Dec 8 '17 at 15:54
  • $\begingroup$ Ok I see i have to edit my question. The location of those elements is main issue. Not the value. $\endgroup$ – Katarina Dec 8 '17 at 15:56
  • $\begingroup$ I'm using phone, as son as I get to my computer I'll try RegionFunction. $\endgroup$ – Katarina Dec 8 '17 at 16:02
0
$\begingroup$

I don't know is this common but I manage to use region function and as I got no other answers and this might be helpful to others here is solution.

ListPlot3D[Flatten[dataPoints, 1], 
 AxesLabel -> {Style[x, Medium, Blue], Style[y, Medium, Blue], 
   Style[u, Medium, Blue]}, 
 ColorFunction -> Function[{x, y, z}, Hue[z]], 
 RegionFunction -> 
  Function[{x, y, z}, 
   Xor[0 <= x <= 200 && 0 <= y <= 200, 
    50 <= x <= 150 && 50 <= y <= 150]], PlotRange -> All]

I used Xor to exclude specific region from a plot and got following solution:

enter image description here

It is similar to the one Jose Antonio Diaz Navas suggested but does not concern z but x and y coordinates and that is the solution I need, thanks to Jose for pointing to RegionFunction

$\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.