필터 지우기
필터 지우기

How to plot a function with 1x1 sym value

조회 수: 5 (최근 30일)
Luigi Stragapede
Luigi Stragapede 2020년 5월 12일
댓글: Luigi Stragapede 2020년 5월 12일
I want to plot T(OMEGA):
T=real(1i*n*alfak*(besselj(np+1,alfak))^2*(conj(A3)*B3-A3*conj(B3)))
where:
  • np is known
  • n is known
  • alfak is known
  • besselj(np+1, alfak) is the bessel function of the fisrt kind of order np+1
But A3 and B3 depends on OMEGA and they appears as 1x1 sym in the workspace.
I used this code:
fplot(@(OMEGA) T)
grid on
but this message appears on the command window:
Warning: Function behaves unexpectedly on array inputs. To improve performance, properly vectorize your function to return an output with
the same size and shape as the input arguments.
> In matlab.graphics.function.FunctionLine>getFunction
In matlab.graphics.function.FunctionLine/updateFunction
In matlab.graphics.function.FunctionLine/set.Function_I
In matlab.graphics.function.FunctionLine/set.Function
In matlab.graphics.function.FunctionLine
In fplot>singleFplot (line 232)
In fplot>@(f)singleFplot(cax,{f},limits,extraOpts,args) (line 191)
In fplot>vectorizeFplot (line 191)
In fplot (line 161)
In Untitled2 (line 103)
Warning: Error updating FunctionLine.
The following error was reported evaluating the function in FunctionLine update: Unable to convert expression into double array.
which is the problem? How can I solve it?

답변 (1개)

Walter Roberson
Walter Roberson 2020년 5월 12일
Replace
fplot(@(OMEGA) T)
with
fplot(T)
Remember that fplot will be passing in a vector of particular values that it wants to evaluate the function at, but no matter what size of input it passes in, you are always returning the scalar value T, which is a symbolic expression involving the unresolved variable OMEGA .
When you use @(VARIABLE) EXPRESSION where EXPRESSION is a symbolic expression involving VARIABLE, then MATLAB will not substitute the parameter passed in for the value of the variable. You could, though,
fplot( @(omega) subs(T, OMEGA, omega) )
but you might as well just
fplot(T)
  댓글 수: 1
Luigi Stragapede
Luigi Stragapede 2020년 5월 12일
I tried but nothing. I have this message:
Error using fplot>singleFplot (line 227)
Input must be a function or functions of a single variable.
Error in fplot>@(f)singleFplot(cax,{f},limits,extraOpts,args) (line 191)
hObj = cellfun(@(f)
singleFplot(cax,{f},limits,extraOpts,args),fn{1},'UniformOutput',false);
Error in fplot>vectorizeFplot (line 191)
hObj = cellfun(@(f)
singleFplot(cax,{f},limits,extraOpts,args),fn{1},'UniformOutput',false);
Error in fplot (line 161)
hObj = vectorizeFplot(cax,fn,limits,extraOpts,args);
Error in calcolo_grafico_coppia (line 104)
fplot(T)
Do you have other ideas?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Assumptions에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by