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 comentarios

darova
darova el 14 de Ag. de 2021
imagesc is a 3d representation of data. You have only X and Y. Do you have Z?
Nisar Ahmed
Nisar Ahmed el 16 de Ag. de 2021
Yes, I have z as XY coordinates like for the first VP1,TWT1 plot,the XY are X = 458158.62, Y = 6526223.5.
Walter Roberson
Walter Roberson el 16 de Ag. de 2021
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
Nisar Ahmed el 16 de Ag. de 2021
Z values are just position coordinates of each plot. So I think it has nothing to do with color map.
I have figure (left plot) and want to make color display (right) from the left plot.
Walter Roberson
Walter Roberson el 16 de Ag. de 2021
Editada: Walter Roberson el 16 de Ag. de 2021
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
Nisar Ahmed el 26 de Ag. de 2021
Hi,
How can I make a matrix of my above posted data like suppose TWT1 is same for al VP1, VP2, VP3, etc
Walter Roberson
Walter Roberson el 26 de Ag. de 2021
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
Nisar Ahmed el 26 de Ag. de 2021
@Walter Roberson thank you,
I have Z as distance (d) and I am generating it know. So plot like imagesc, can I make a matrix like
vp = [VP1 VP2 VP3 VP4 VP5 VP6 VP7.....]
Nisar Ahmed
Nisar Ahmed el 27 de Ag. de 2021
Now I have z file as well. Please see the attached data:
I want to plot imagesc(d, TWTi, vp). I mean TWTi along y axis and is common for all vp curves. while d is the distance between each vp curve.
Can you please help me to produce a figure.

Iniciar sesión para comentar.

Respuestas (1)

Walter Roberson
Walter Roberson el 13 de Ag. de 2021

0 votos

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 comentarios

Nisar Ahmed
Nisar Ahmed el 14 de Ag. de 2021
I did not understand your answer, I visited the and did not find it useful. Maybe I have not expained my question properly.
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
Nisar Ahmed el 16 de Ag. de 2021
When I tried to run your code, following error appears
Error using griddedInterpolant
The grid vectors must contain unique points.
Error in interp1 (line 151)
F = griddedInterpolant(X,V,method);
Error in Real_data_inversion>@(v,t)interp1(v,t,VP_lin)
Error in Real_data_inversion (line 211)
TWTs_interp = cellfun(@(v,t) interp1(v,t,VP_lin), VPs(:), TWTs(:), 'uniform', 0);
Walter Roberson
Walter Roberson el 16 de Ag. de 2021
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.

Iniciar sesión para comentar.

Preguntada:

el 13 de Ag. de 2021

Comentada:

el 27 de Ag. de 2021

Community Treasure Hunt

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

Start Hunting!

Translated by