adding a regression area to a 3d plot
조회 수: 11 (최근 30일)
이전 댓글 표시
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!
댓글 수: 0
답변 (1개)
Amir
2014년 8월 13일
편집: Amir
2014년 8월 13일
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.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Scatter Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!