Why doesn't Matlab simplify units to Ohms..

조회 수: 1 (최근 30일)
Ashley Imhoff
Ashley Imhoff 2019년 2월 13일
답변: Aiswarya 2024년 2월 28일
u = symunit;
u0 = (4*pi()*1E-7)*(u.H/u.m);
e0 = 8.854187817*(1e-12)*u.F/u.m;
er = 1;
ur = 1.0;
Z = sqrt(u0/e0);
Zo = unitConvert(Z,'SI','Derived');
Zo = simplify(expand(Z));
Zo = vpa(Zo,5) %The Units should be Ohms

답변 (1개)

Aiswarya
Aiswarya 2024년 2월 28일
Hi,
I understand that you are trying to simplify and convert your variable "Zo" to Ohms. The issue is that the function "unitConvert" does not simplify square roots, but only takes care of the units inside of them. You can resolve the issue by referring to the following modified code:
Z = sqrt(u0/e0);
% Convert to SI units and then simplify
Zo = unitConvert(Z, 'SI');
Zo = simplify(expand(Zo));
Zo = unitConvert(Zo, 'SI', 'Derived'); % Using 'Derived' resolves the units to 'Ohm'
Zo = vpa(Zo,5);
You can observe that the unit of "Zo" is "Ohms".

카테고리

Help CenterFile Exchange에서 Units of Measurement에 대해 자세히 알아보기

태그

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by