HELP required: Undefined function 'mpower' for input arguments of type 'cell' ... Plus another error!
显示 更早的评论
My aim is to have a expression for 'd' in terms of other variables (L, D & k) and here is the code:
syms L D k d;
n = 10;
t = (L-D)/n;
x1 = 0;
F1 = 0;
x2 = 0;
F2 = 0;
for i = 0:((n-2)/2)
x1 = (2*i+1)*t;
F1 = F1 + k*[(L-D)^2-x1^2] / {{1 - [k*[(L-D)^2-x1^2]]^2}^(1/2)};
end
for i = 1:((n-2)/2)
x2 = 2*i*t;
F2 = F2 + k*[(L-D)^2-x2^2] / {{1 - [k*[(L-D)^2-x2^2]]^2}^(1/2)};
end
d = t*{k*(L-D)^2+4*F1+2*F2}/3;
The ERRORS are as follows:
{
Undefined function 'mpower' for input arguments of type 'cell'.
Error in Symbolictest (line 10)
F1 = F1 + k*[(L-D)^2-x1^2] / {{1 - [k*[(L-D)^2-x1^2]]^2}^(1/2)};
}
回答(1 个)
Star Strider
2015-5-10
The curly brackets {} create a cell. Replace them with parentheses:
F1 = F1 + k*[(L-D)^2-x1^2] / ((1 - [k*[(L-D)^2-x1^2]]^2)^(1/2));
and:
F2 = F2 + k*[(L-D)^2-x2^2] / ((1 - [k*[(L-D)^2-x2^2]]^2)^(1/2));
and:
d = t*(k*(L-D)^2+4*F1+2*F2)/3;
Also, you need to subscript the variables you want to keep that you create in your for loops. Otherwise, you are keeping only the result of the last iteration.
This should eliminate the ‘cell’ errors. I leave it to you to troubleshoot the rest of your code.
类别
在 帮助中心 和 File Exchange 中查找有关 Common Operations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!