adding a regression area to a 3d plot

First of all I would like to mention that I don't know much about matlab programming but I'm trying to do something that I think is simple.
I created a 3d scatterplot using the "plots" tab. My data set has 3 arrays; x, y, and z.
That was easy enough. Now I would like to add a best fit surface area to the plot. How do I do that? I tried following other questions that were asked but I wasn't able to understand the code. I am not creating a function. I am just using using the command window with the x,y, and z arrays in work space.
Please help!
Thanks!

回答 (1 件)

Amir
Amir 2014 年 8 月 13 日
編集済み: Amir 2014 年 8 月 13 日

0 投票

Hi Mostafa. Try this code:
x=5*rand(1,1000); % 1000 random number between 0 and 5
x=x'; % transpose (row to vector)
y=sin(x)/3;
z=x.^2-y.^2 + sin(x.*y) + 5 * rand(size(x)); % rand for some noise
f = fit( [x, y], z, 'poly23' );
plot(f, [x,y], z);
Hope this helps you.

カテゴリ

質問済み:

2014 年 8 月 13 日

編集済み:

2014 年 8 月 13 日

Community Treasure Hunt

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

Start Hunting!

Translated by