Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Plot xyz surface data from matrix or file

829 views
Skip to first unread message

Carlos

unread,
Dec 15, 2010, 10:03:05 AM12/15/10
to
Hello.

How can I do surface plot of xyz existent data in a matrix (column 1 = x, column 2 = y, column 3 = z)?

I don't want calculate anything, so I don't want to do the usual "tuturial" example of:
[vX,vY]=meshgrid(x,y)
vZ = function(vX,vY)
surf(vX,vY,vZ)

And the intervals in x axis (or y axis) are not constant over the domain

So I just want to plot existent x y z data which are a matrix like this

0 0 0
0 0.000267 0
0 0.000534 0
0 0.000801 0
0 0.001068 0
0 0.001335 0
0.0006 0 0
0.0006 0.000267 0.13304
0.0006 0.000534 0.19506
0.0006 0.000801 0.19506
0.0006 0.001068 0.13304
0.0006 0.001335 1.6067e-016
0.0012 0 0
0.0012 0.000267 0.16342
0.0012 0.000534 0.2439
0.0012 0.000801 0.2439
0.0012 0.001068 0.16342
0.0012 0.001335 1.9014e-016
0.0018 0 0
0.0018 0.000267 0.17079
0.0018 0.000534 0.25582
0.0018 0.000801 0.25582
0.0018 0.001068 0.17079
0.0018 0.001335 1.9725e-016

and obtain a figure like the one in this url:

http://peniche-online.com/images/gnuplot.jpg

which was obtained with gnuplot using a file where the matrix was dumped.

Thanks,
carlos

Richard_Willey

unread,
Dec 15, 2010, 10:46:12 AM12/15/10
to
If you have access to Curve Fitting Toolbox, you can do the following

foo = fit(X,Y,Z, 'cubicinterp');
plot(foo)


"Carlos " <cd...@yahoo.com> wrote in message
news:iealb9$dj0$1...@fred.mathworks.com...

Carlos

unread,
Dec 15, 2010, 5:41:04 PM12/15/10
to
"Richard_Willey" <rwi...@mathworks.com> wrote in message <ieans8$8nf$1...@fred.mathworks.com>...

> If you have access to Curve Fitting Toolbox, you can do the following
>
> foo = fit(X,Y,Z, 'cubicinterp');
> plot(foo)
>
>


Hi!
Thanks for your answer.
I think I have the curving tool box, but for some unknown reason to me (I don't understant very much about matlab) the fit function generates errors.
However, and despite I doubt the graphic quality I get something what I want using the griddata and surf functions that I saw somewhere while researching in the net (probably following links from fit or surf functions):

yvector = perfil_vector(:,5);
zvector = perfil_vector(:,7);
vvector = perfil_vector(:,8);

yi = 0:0.00001:0.03;
zi = 0:0.000001:0.001335;

[YI,ZI] = meshgrid(yi,zi);

VI = griddata(yvector,zvector,vvector,YI,ZI);

mesh(YI,ZI,VI), hold

%plot3(yvector,zvector,vvector,'o'), hold off
surf(YI,ZI,VI);
shading flat;

http://peniche-online.com/images/matlab.jpg


Steven_Lord

unread,
Dec 15, 2010, 10:50:49 PM12/15/10
to

"Carlos " <cd...@yahoo.com> wrote in message

news:iebg60$33f$1...@fred.mathworks.com...


> "Richard_Willey" <rwi...@mathworks.com> wrote in message
> <ieans8$8nf$1...@fred.mathworks.com>...
>> If you have access to Curve Fitting Toolbox, you can do the following
>>
>> foo = fit(X,Y,Z, 'cubicinterp');
>> plot(foo)
>>
>>
>
>
> Hi!
> Thanks for your answer.
> I think I have the curving tool box, but for some unknown reason to me (I
> don't understant very much about matlab) the fit function generates
> errors.

Show the group how exactly you call FIT and the exact full text of the error
message you received and someone may be able to offer a suggestion.

*snip*

--
Steve Lord
sl...@mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlab.wikia.com/wiki/FAQ
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

James

unread,
May 17, 2012, 12:24:07 PM5/17/12
to
There is just a slight error in the syntax of that bit.

foo = fit([X,Y], Z, 'cubicinterp');
plot(foo)

thanks for the good idea to use the fit toolbox to do the lifting of the matrix creation.



"Richard_Willey" <rwi...@mathworks.com> wrote in message <ieans8$8nf$1...@fred.mathworks.com>...

AEDIL

unread,
Aug 22, 2014, 6:03:07 AM8/22/14
to
"Carlos " <cd...@yahoo.com> wrote in message <iebg60$33f$1...@fred.mathworks.com>...
hi carlos,

I am also facing the same problem. I have the column matrices x,y and z. there aren't any direct relation between x & y and z. you have mentioned above that you were able to plot the data using gnuplot and also matlab. can you explain how you do that. please help me to crack this this problem.

regards
Aedil
0 new messages