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.

Antworten (1)

Torsten
Torsten am 20 Apr. 2023
Bearbeitet: Torsten am 20 Apr. 2023

0 Stimmen

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

1 Kommentar

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.

Melden Sie sich an, um zu kommentieren.

Kategorien

Gefragt:

Kai
am 20 Apr. 2023

Kommentiert:

Kai
am 21 Apr. 2023

Community Treasure Hunt

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

Start Hunting!

Translated by