Entering values into a function handle output
Show older comments
Hello, I have a function, and I can calculate P from the command window, but when I use this function, my output yh has P(1), P(2), etc, but what I want it do to is replace those with the actual value calculated
function yh = BreakRod(cellData)
Y = cellData{1,:}';
U = cellData{2,:}';
V = cellData{3,:}';
A = Adef(U,V);
P = A\Y;
yh = @(U,V) P(1) + P(2)*exp(U.^2) + P(3)*sqrt(V) + P(4)*U.*V;
end
function A = Adef(U,V)
N = size(U,1);
A = ones(N,4);
A(:,2) = exp(U.^2);
A(:,3) = sqrt(V);
A(:,4) = U.*V;
end
cellData{:}
ans =
1 4 5 6
ans =
1.0000 2.0000 3.0000 0.5000
ans =
2 1 7 3
P
P =
30.4842
0.0299
-3.4979
-12.3093
yh = BreakRod(cellData)
yh =
@(U,V)P(1)+P(2)*exp(U.^2)+P(3)*sqrt(V)+P(4)*U.*V
Accepted Answer
More Answers (0)
Categories
Find more on Whos in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!