polyfit vs csapi revolve - can't square the integral on csapi

Hi all,
I'm trying to compare the volumes of two revolves around the x axis, defined by the same set of (x,y) coordinates. One is a polyfit approximation, which works very well. I'm now trying to do the same with a csapi spline that goes through the actual points, but can't seem to get the integral right. The polyfit works very well;
p=polyfit(x,y,10);
Vp=pi*(polyint(conv(p,p)));
But I can't get the csapi version to work at all;
c=csapi(x,y);
Vs=pi*diff(fnval(fnint(c)^2,[0 143]));
It just spits out errors all the time. Area integrals for both work just fine;
Ap=polyint(p);
As=fnint(c);
The error I get is
> In polyfit (line 84)
In Vase (line 8)
Operator '.^' is not supported for operands of type 'struct'.
Error in ^ (line 22)
Z = X.^Y;
Error in Vase (line 15)
Vs=pi*diff(fnval(fnint(c)^2,[0 143])); %Volume of Spline revolve
What am I doing wrong? How do I solve this?
Best of thanks inadvance,
Kai.

답변 (1개)

Torsten
Torsten 2023년 4월 20일
편집: Torsten 2023년 4월 20일

0 개 추천

Take a look here on how to to generate a spline function squared and integrate it:

댓글 수: 1

Thank you very much - I guess I should have found that on my search but didn't,
I'll try to make this work with the csapi spline...
Thanks again,
Kai.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Spline Postprocessing에 대해 자세히 알아보기

질문:

Kai
2023년 4월 20일

댓글:

Kai
2023년 4월 21일

Community Treasure Hunt

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

Start Hunting!

Translated by