Plot xyz surface data from matrix or file

  • Follow


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
0
Reply Carlos 12/15/2010 3:03:05 PM

If you have access to Curve Fitting Toolbox, you can do the following

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


"Carlos " <cddsc@yahoo.com> wrote in message 
news:iealb9$dj0$1@fred.mathworks.com...
> 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 

0
Reply Richard_Willey 12/15/2010 3:46:12 PM


"Richard_Willey" <rwilley@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

 
0
Reply Carlos 12/15/2010 10:41:04 PM


"Carlos " <cddsc@yahoo.com> wrote in message 
news:iebg60$33f$1@fred.mathworks.com...
> "Richard_Willey" <rwilley@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
slord@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 

0
Reply Steven_Lord 12/16/2010 3:50:49 AM

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" <rwilley@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)
> 
> 
> "Carlos " <cddsc@yahoo.com> wrote in message 
> news:iealb9$dj0$1@fred.mathworks.com...
> > 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 
0
Reply jbittn2 (1) 5/17/2012 4:24:07 PM

4 Replies
1228 Views

(page loaded in 0.09 seconds)

Similiar Articles:













7/25/2012 10:27:23 AM


Reply: