How to plot surf or imagesc for my data?
이전 댓글 표시
Hi,
This is my figure code, it comprises on 38 VP vs TWT plots as:
h = plot(VP1,TWT1,VP2+500,TWT2,VP3+1000,TWT3,VP4+1500,TWT4,VP5+2000,TWT5,VP6+2500,TWT6,...
VP7+3000,TWT7,VP8+3500,TWT8,VP9+4100,TWT9,VP10+4500,TWT10,VP11+5000,TWT11,VP12+5500,...
TWT12,VP13+6000,TWT13,VP14+6500,TWT14,VP15+7000,TWT15,VP16+7500,TWT16,VP17+8000,TWT17,...
VP18+8500,TWT18,VP19+9000,TWT19,VP20+9500,TWT20,VP21+10000,TWT21,VP22+10500,TWT22,...
VP23+11000,TWT23,VP24+11500,TWT24,VP25+12500,TWT25,VP26+13000,TWT26,VP27+13500,TWT27...
,VP28+14000,TWT28,VP29+14500,TWT29,VP30+15000,TWT30,VP31+15500,TWT31,VP32+16000,TWT32,...
VP33+16500,TWT33,VP34+17000,TWT34,VP34+17500,TWT34,VP35+18000,TWT35,VP36+18500,TWT36...
,VP37+19000,TWT37,VP38+19500,TWT38);
I want to to plot it as imagesc rather than vertical curves. How can I do it?
댓글 수: 9
darova
2021년 8월 14일
imagesc is a 3d representation of data. You have only X and Y. Do you have Z?
Nisar Ahmed
2021년 8월 16일
Walter Roberson
2021년 8월 16일
You have a number of X and Y values, but it is not clear to us what your Z values are. For example for X = 458158.62 Y = 6526223.5 then what color do you want associated ? What variable holds the information that can be used to compute the color?
Or is the color intended to be calculated by relative position, such as computing the total length of the line described by VP1, TWT1 and then coloring any given point proportional to the distance the point is along the line?
Or perhaps you want to set up a gradient with the minimum X over all the VP* variables should have a 0 red component, and the maximum X over all the VP* variables should have maximum red component, and every point should be assigned a proportionate red componet; and the same kind of thing with setting a green component according to the portion of Y value? So each point would have a computed red component and green component according to its position? So one corner would be black, one corner would be red, one corner would be green, one corner (opposite black) would be yellow (red+green) ?
Nisar Ahmed
2021년 8월 16일
Walter Roberson
2021년 8월 16일
편집: Walter Roberson
2021년 8월 16일
You cannot do that, not with the information you have available.
Z values are just position coordinates of each plot
No they are not. You have an x position coordinate and a y position coordinate for each point, a total of two coordinates per point. You should only have one Z value for each point.
Look at your plot. In the horizontal middle, any given x coordinate might imply orange or yellow or green or blue or purple. In the vertical middle, any given y coordinate might imply green or dark green or blue. At the right hand side you hae blue between two green patches, which is not something that can be explained by x or y coordinates of the points and cannot be explained by something like distance from a particular object.
You need the information about whether a particular point is orange or yellow or green or blue or purple, either as a variable or as a function based upon position (and it would have to be a pretty complicated function.)
Nisar Ahmed
2021년 8월 26일
Walter Roberson
2021년 8월 26일
If you use the same TWT for all VP* entries, you still have the problem that the VP* supplies the X data and the TWT* supplies the Y data, but you do not have any Z (or color) data.
Nisar Ahmed
2021년 8월 26일
Nisar Ahmed
2021년 8월 27일
답변 (1개)
Walter Roberson
2021년 8월 13일
0 개 추천
Use the Computer Vision insertShape() function to "draw" the lines into an array. Afterwards you can image() the resulting array.
imagesc() is not really suitable for this situation: you would be storing colored pixels into the array, not relative values.
Perhaps I am misunderstanding what kind of plot you were looking for ??
If your primary purpose is just display, then I would not recommend going through the trouble of doing the insertShape -- not unless you are building an image to display on a Raspberry Pi display or to store into a file.
댓글 수: 4
Nisar Ahmed
2021년 8월 14일
Walter Roberson
2021년 8월 14일
Guessing about what you might want, as you did not explain:
VPs = {VP1, VP2, VP3, VP4, VP5, VP6, VP7, VP8, VP9, VP10, VP11, VP12, VP13, VP14, VP15, VP16, VP17, VP18, VP19, VP20, VP21, VP22, VP23, VP24, VP25, VP26, VP27, VP28, VP29, VP30, VP31, VP32, VP33, VP34, VP35, VP36, VP37, VP38};
TWTs = {TWT1, TWT2, TWT3, TWT4, TWT5, TWT6, TWT7, TWT8, TWT9, TWT10, TWT11, TWT12, TWT13, TWT14, TWT15, TWT16, TWT17, TWT18, TWT19, TWT20, TWT21, TWT22, TWT23, TWT24, TWT25, TWT26, TWT27, TWT28, TWT29, TWT30, TWT31, TWT32, TWT33, TWT34, TWT35, TWT36, TWT37, TWT38};
min_VP = min(cellfun(@min, VPs));
max_VP = max(cellfun(@max, VPs));
longest = max(cellfun(@length, VPs));
VP_lin = linspace(min_VP, max_VP, longest);
TWTs_interp = cellfun(@(v,t) interp1(v,t,VP_lin), VPs(:), TWTs(:), 'uniform', 0);
TWT_img = cell2mat(TWTs_interp);
imagesc(TWT_img, 'XData', [min_VP, max_VP]);
Nisar Ahmed
2021년 8월 16일
Walter Roberson
2021년 8월 16일
At least one of your VP* variables contains duplicate points; perhaps the line doubles back on itself.
In that situation, I am having trouble imagining what result you are hoping for.
카테고리
도움말 센터 및 File Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
