fliping a contour plot while maintaining the original.

hello all, i am trying to flip a contourplot but i want to have it show the original and the flipped picture on the same graph. i have included a picture to show that i want this plot to be flipped about the y axis while still mainting the original contour as they should be identical but flipped if that makes sense.

 Risposta accettata

Consider for a moment the center partial ellipse. At the moment, it is a truncated ellipse, with a straight line running along the edge of it.
Now, if you were to flip the contourplot and put the new one immediately beside the current one, assuming you could get the edges to line up, what you would see would not be a full ellipse: it would be a full ellipse with a line down the middle. Is that what you would want?
If it is what you would want, then it is possible to copy the existing contour object, and then in the copy, take the negative of the X coordinates. There would be a line through the middle if you did this.
If you do not want the line down the middle, then you should mirror your data in an array, and do a single contour based on that. It is easiest to do that while you still have the data on hand in variables, but it is also possible to grab the values out of the contour object and contour based on that plus its mirror, and adjust the data in the original contour object.

6 Commenti

how do i mirror a matrix then in order to do that and then plot it?
so basically i have a N by N matrix and i guess i need to mirror the matrix to not have the streak down the middle. how do i go about doing that?
newZ = [Z, fliplr(Z)];
but you should also consider
newZ = [Z, fliplr(Z(:,1:end-1))];
That is, do you want [1 2 3 4 5 5 4 3 2 1] or do you want [1 2 3 4 5 4 3 2 1] ?
You will also need to construct X coordinates, but those turn out to be difficult to construct if you duplicate the last column and you assume the coordinates are not equally spaced. For example,
Z = [10 20 30 40 50]
X = [1 2 4 7 11]
then it would make sense for the mirrored 10 to be the same distance from the mirrored 20 as the 10 is from the 20.
nZ = [10 20 30 40 50 50 40 30 20 10]
nX = [ 1 2 4 7 11 ?+0 ?+4 ?+7 ?+9 ?+10]
but how far should the mirrored 50 be considered to be from the original 50?
The question is easily answered if the rule is that the points are equally spaced in X, but not easily answered if they are not equally spaced in X. Not, that is, unless you do not mirror the last -- if you do not mirror the last then it is not difficult to program.
so i mean right now i have everything evenly spaced in teh r and theta direction. therefore everything should be evenly spaced in both directions? i think i have that right. just so i understand this for the code you hvae end is my end value is that correct so in my case it would be N since my matrix is N by N. and same with how i owuld need to mirror r since it is N length long. so basically i would need to do newT = [T. fliplr(z(:,1:N-1))] tehn do the same with my array for R and theta?
also i could do this with x and y but wouldnt i need to change the x value to be negative at least in order to flip it over the x axis. so in this case i would need it to be equal but opposite on the x axis. but the values for T should all be the same. if that makes sense?
nvm your
newnewZ = [Z, fliplr(Z)];
did exactly what i needed it to without a line.

Accedi per commentare.

Più risposte (0)

Categorie

Prodotti

Release

R2021a

Tag

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by