# plot with input arguments

조회 수: 1(최근 30일)
Commented: Roger Nadal 11 Dec 2019
i want to subplot 4 string containg cell array from ( sin, cos, tan,sinh) and vector (+,o,*,x,s) and the mathmatical function should be ploted in interval (-2pi,2pi)with step 0.3

로그인 to comment.

### 채택된 답변

Walter Roberson 5 Dec 2019
funs_cell = {'sin', 'cos', 'tan', 'sinh'};
markers = {'+', 'o', '*', 'x', 's'};
funs = cellfun(@str2fun, funs_cell, 'uniform', 0);
for K = 1 : length(funs)
plot(x, funs{K}(x), markers{K}, 'DisplayName', funs_cell{K});
hold on
end

#### 댓글 수: 33

표시 이전 댓글 수: 30
Walter Roberson 11 Dec 2019
In MATLAB,
if numel(fun_cell)||numel(color)~=4 Error(msg)
would be interpreted as
if (numel(fun_cell) ~= 0) || (numel(color) ~= 4)
error(msg)
end
MATLAB itself has absolutely no transitive operators of the form
expression1 operator1 expression2 operator2 value
being intepreted as
(expression1 operator2 value) operator1 (expression2 operator2 value)
In MATLAB you need to be explicit,
if numel(fun_cell) ~= 4 || numel(color) ~= 4
error(msg)
end