MATLAB matrix using in function

조회 수: 11 (최근 30일)
Mehmet SARIARSLAN
Mehmet SARIARSLAN 2020년 11월 16일
편집: Steven Lord 2020년 11월 16일
I can't use matrix in my functions. Can you help me?
u=symunit;
M=7.75*u.cm
R=2.54*u.m
a_ef=10:10:100
deltap=-7.55*(M^2/R^2)*(1/(0.116+log(R/2.405*a_ef)))
Error using symengine
Invalid operands.
Csym = mupadmex(op,args{1}.s, args{2}.s, varargin{:});
Error in / (line 382)
X = privBinaryOp(A, B, 'symobj::mrdivide');

답변 (2개)

Steven Lord
Steven Lord 2020년 11월 16일
Use element-wise division for the operations that will operate on the vector a_ef.
deltap=-7.55*(M^2/R^2)*(1./(0.116+log(R./2.405*a_ef)));
The first division, M^2/R^2, is dividing two scalars so ./ is not required (but it would work.)
  댓글 수: 2
Mehmet SARIARSLAN
Mehmet SARIARSLAN 2020년 11월 16일
Problem isn't solved.
u=symunit;
M=7.75*u.cm
R=2.54*u.m
a_ef=(10:10:100)*u.mm
deltap=-7.55*((M^2)/(R^2))*(1/(0.116+log((R)/2.405*a_ef)))
Error using symengine
Invalid operands.
Csym = mupadmex(op,args{1}.s, args{2}.s, varargin{:});
Error in / (line 382)
X = privBinaryOp(A, B, 'symobj::mrdivide');
Steven Lord
Steven Lord 2020년 11월 16일
편집: Steven Lord 2020년 11월 16일
You did not replace / with ./ in the last line. When I do I can run it. If this resolves the problem please delete your flag and accept the answer. Thanks.
u=symunit;
M=7.75*u.cm;
R=2.54*u.m;
a_ef=(10:10:100)*u.mm;
deltap=-7.55*((M^2)/(R^2))*(1./(0.116+log((R)./2.405*a_ef)));
deltap(1)
ans = 
simplify(deltap(1))
ans = 

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


Mehmet SARIARSLAN
Mehmet SARIARSLAN 2020년 11월 16일
All my code
u=symunit;
M=7.75*u.cm
R=2.54*u.m
a_ef=(10:10:100)*u.mm
deltap=-7.55*((M^2)/(R^2))*(1/(0.116+log((R)/2.405*a_ef)))
%plot(deltap,a_ef)
M =
R =
a_ef =
Error using symengine
Invalid operands.
Csym = mupadmex(op,args{1}.s, args{2}.s, varargin{:});
Error in / (line 382)
X = privBinaryOp(A, B, 'symobj::mrdivide');

카테고리

Help CenterFile Exchange에서 Multirate Signal Processing에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by