Construction of various plots according to data with the NDGrid structure
6 views (last 30 days)
Show older comments
This question addresses a slightly different aspect of the problem originally asked in the link above.
There are a number of parameters , for which a multidimensional computational grid is formed. Then the condition of fulfillment/non-fulfillment of the inequality is calculated.
[X Y Z]=ndgrid(-1:0.05:1,-1:0.05:1,-1:0.05:1);
Xgen=[];
Ygen=[];
Zgen=[];
F = X.^2 + Y.^2 + Z.^2;
cond1 = F > 1/2;
cond2 = F < 1;
cond1 = double(cond1);
cond2 = double(cond2);
cond1(cond1 == 0) = NaN;
cond2(cond2 == 0) = NaN;
cond = cond1.*cond2;
X = X.*cond; %A "mask" is superimposed on the parameters, showing at which points in space the inequality is fulfilled and at which it is not.
Y = Y.*cond;
Z = Z.*cond;
And then I got problems. I want to visualize the data obtained in a visual form so that I can see the internal structure (for this I thought to use the Contour, Contour3 or something like that) and use the resulting graphs to choose such a combination of parameters so that the inequality is fulfilled.
I decided to turn all the received data into two-dimensional tables with the following code:
for i=1:40 %Number of "pages" of the NDgrid
Xgen = [Xgen; X(:,:,i)];
end
for i=1:40
Ygen = [Ygen; Y(:,:,i)];
end
for i=1:40
Zgen = [Zgen; Z(:,:,i)];
end
But even here I did not manage to build anything digestible, except for all the "layers" received.
surf(Xgen,Ygen,Zgen)
I tried to apply the Contour and Contour3 commands, but without success. I get just empty plots, because the values of the z-axes are constant. I hoped that they would help me visualize the structure of the resulting computational domain. I don't know any other commands. Please suggest a way out.
0 Comments
Answers (0)
See Also
Categories
Find more on 2-D and 3-D Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!