Upper limit a symbolic vector
5 views (last 30 days)
Show older comments
Hi,
I need to resolve the following problem:
I have a vector of input numbers (in) and I have to multiply it for a variable (a). My output (out) must be that vector that has an upper limit of 100 (clearly the output depends on the variable). Then I need to sum the vector "out" and divide it for "a" and plot the result in function of "a". I tried this way:
syms a
A=in*a;
out=min(A,100);
fun=sum(out)/a;
fplot(fun)
As far as I understand though I cannot run the "min" command because that instruction doesn't work on a symbolic vector. Anyway the error is:
Error using symengine
Input arguments must be convertible to floating-point numbers.
Error in sym/privBinaryOp (line 1030)
Csym = mupadmex(op,args{1}.s, args{2}.s, varargin{:});
Error in sym/min (line 78)
C = privBinaryOp(X, Y, 'symobj::zipWithImplicitExpansion', 'symobj::minComplex');
In case it's important for the help, the aim of the excersise is writing a mathematical function (fun) based on the variable "a"; the actual value of "a" will be determined only at the end minimizing the function "fun".
Thank you in advance
0 Comments
Answers (1)
Walter Roberson
on 29 Jun 2021
in = randi([-9 9], 1, 50)
Min = @(P,Q) arrayfun(@(p,q) piecewise(p <= q, p, q), P, Q);
syms a
A = in*a
out = Min(A,repmat(100,size(A)));
fun = sum(out)/a
fplot(fun, [-100 100])
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

