How do I create a linear function of cells from a cell array?

1 Ansicht (letzte 30 Tage)
Philipp Deutscher
Philipp Deutscher am 3 Jan. 2019
Beantwortet: Sachin Meena am 7 Jan. 2019
As seen below, I can't convert my cell array into a function:
% Profilverschiebung:
m_1 = 1
m_1 = 1
alpha1 = 14 * pi/180;
invalpha1 = tan(alpha1) - alpha1;
invalpha_w1 = @(x1) 2*(x1(1)+x1(2))*tan(alpha1) / (z(1)+z(2)) + invalpha1;
alpha_w1 = @(x1) (3*invalpha_w1)^(1/3) - 2/5*invalpha_w1;
d_w1 = cell(3,1);
n = 3;
k=0;
for i = 1:n
d_w1{i} = @(x1) z_gewaehlt(i)*m_1 * cos(alpha1)/cos(alpha_w1)
end
d_w1 = 3×1 cell array
{@(x1)z_gewaehlt(i)*m_1*cos(alpha1)/cos(alpha_w1)}
{0×0 double }
{0×0 double }
d_w1 = 3×1 cell array
{@(x1)z_gewaehlt(i)*m_1*cos(alpha1)/cos(alpha_w1)}
{@(x1)z_gewaehlt(i)*m_1*cos(alpha1)/cos(alpha_w1)}
{0×0 double }
d_w1 = 3×1 cell array
{@(x1)z_gewaehlt(i)*m_1*cos(alpha1)/cos(alpha_w1)}
{@(x1)z_gewaehlt(i)*m_1*cos(alpha1)/cos(alpha_w1)}
{@(x1)z_gewaehlt(i)*m_1*cos(alpha1)/cos(alpha_w1)}
Geometriebedingung_Planetenstufe = @(x1) d_w1{1} + 2 * d_w1{2} + d_w1{3};
x1_0 = [0 0 0]
x1_0 = 1×3
0 0 0
x1 = fminsearch(Geometriebedingung_Planetenstufe, x1_0)
And thats my error log:
Undefined operator '*' for input arguments of type 'function_handle'.
Error in Berechnung_Zaehnezahlen_und_Profilverschiebung_MEL_KU_2>@(x1)d_w1{1}+2*d_w1{2}+d_w1{3}
Error in fminsearch (line 200)
fv(:,1) = funfcn(x,varargin{:});

Antworten (1)

Sachin Meena
Sachin Meena am 7 Jan. 2019
The error arises as you are trying to multiply a function handle with scalar 2. The content of your cell array d_w1 are function handles that take a single argument as input. While using them in defining "Geometriebedingung_Planetenstufe", you are not providing these handles any input, hence the error. I am not sure as to what you wish to achieve, but you probably wish to do this.
Geometriebedingung_Planetenstufe = @(x1) d_w1{1}(x1) + 2 * d_w1{2}(x1) + d_w1{3}(x1);

Kategorien

Mehr zu Multidimensional Arrays finden Sie in Help Center und File Exchange

Produkte


Version

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by