Filter löschen
Filter löschen

Temperature Profile Plot on Cylinder

15 Ansichten (letzte 30 Tage)
Jared Hubach
Jared Hubach am 29 Jan. 2018
Kommentiert: Benjamin Kraus am 1 Feb. 2018
I have a set of data in a 1x18 array. This data will be used to create a temperature profile on a cylindrical shaped object. I need to somehow create a plot of this data with a colormap that displays the colors for different temperatures. Everything I have seen so far has not allowed me to 1) change the colorbar to the correct axis and 2)manipulate this data to display in a cylindrical or circle form. The end goal I had in sight was to animate this profile over time, for which I have a lot more data. If it isn't possible to plot this data in 3D form, I would be able to plot 2 separate 2D plots representing the cylinder's front and side view. Any help is much appreciated.

Akzeptierte Antwort

Benjamin Kraus
Benjamin Kraus am 29 Jan. 2018
Bearbeitet: Benjamin Kraus am 29 Jan. 2018
Do you want the data [1x18] to be around the circumference of the cylinder, or along the height of the cylinder?
In either case, you can plot onto a cylinder using the surf command, with some help by the cylinder command:
First I'll create some dummy data to plot:
dummydata = sin(linspace(0,2*pi,18));
Plotting along the circumference:
[X,Y,Z] = cylinder(1,17);
C = [dummydata; dummydata];
surf(X,Y,Z,C);
colorbar
Plotting along the height you have a couple options:
[X,Y,Z] = cylinder(ones(size(dummydata)));
C = repmat(dummydata', 1, size(X,2));
surf(X,Y,Z,C);
colorbar
Or height and radius:
[X,Y,Z] = cylinder(dummydata+2);
C = repmat(dummydata', 1, size(X,2));
surf(X,Y,Z,C);
colorbar
  4 Kommentare
Jared Hubach
Jared Hubach am 30 Jan. 2018
Another concern I have is that the data I have isn't spaced evenly along the outside, like the linspace function provides in the dummydata set. Does that matter or will it affect my ability to plot the data in the correct way?
Benjamin Kraus
Benjamin Kraus am 1 Feb. 2018
Getting a half-cylinder is easy, just call surf with half the data:
surf(X(:,1:11),Y(:,1:11),Z(:,1:11),C(:,1:11))
Getting different "inside" and "outside" data would require two surfaces, one with a slightly smaller radius than the other. Just use hold on to plot two surfaces in the same image.
Merging the circumference and height could be easy or tricky depending on how you want to merge. It could be as simple as merging the data before you call cylinder. Check out my answer to this other post: Depth Label of 3D Graph (Cylinder). The important detail to understand is that X and Y store all the information about radius, but have nothing directly to do with height. Z stores the height information, and really doesn't know anything about radius.
Using non-uniformly spaced data around the circumference is a little harder. You could use interp1 (or any of a number of different techniques) to resample your data uniformly. But a better approach may be to just write your own version of the cylinder function. That shouldn't be too difficult.
If you open the existing cylinder, you can see the implementation is not very complicated:
edit cylinder
I would take a look at the existing implementation, as well as the X, Y, and Z matrices that are created (to see how the data is stored and passed into surf). You should be able to satisfy your requirements either by working with the X, Y, and Z matrices before calling surf, or by creating your own version of cylinder with custom code.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Walter Roberson
Walter Roberson am 29 Jan. 2018
"change the colorbar to the correct axis"
colorbar() accepts an axes as the first argument, if you are referring to which plot the colorbar is to be associated with.
If you are referring to where colorbar shows up on the plot, then colorbar() takes a location parameter such as 'SouthOutside' . If that is not enough control then you can pass a 'Position' name/value pair, and a 'Units' name/value pair: note that coordinates are relative to the figure not to the axes (because the colorbar is typically drawn outside the axes.)
"manipulate this data to display in a cylindrical or circle form"
There are multiple ways of handling this.
One of the easiest ways to use pcolor(), which permits you to pass a matrix of X coordinates and a matrix of Y coordinates for each pixel. However this is really only 2D coordinates and adapting this to 3D in a way that you could rotate your plots is probably not worth it.
pcolor() is really just surface() followed by view(2). You can instead use surface() directly, specifying X, Y, and Z coordinates. If your data is intended to represent "pixels" then you would typically want to use texturemap . Or instead of doing it yourself you could all warp() to do the texture mapping for you.
You can also texture map a patch() object, but there are fewer wrapper interfaces like warp() for doing so. The main reason you might prefer patch() to surface() for something like this is that surface() associates colors with the center of faces -- so if you had 20 x 40 array then you would get 19 x 39 faces. patch() gives you more flexibility about how color is determined, including different ways of configuring interpolation of color.

Kategorien

Mehr zu Orange finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by