필터 지우기
필터 지우기

How can I apply equation to all data in column?

조회 수: 7 (최근 30일)
user1996
user1996 2016년 6월 30일
댓글: Star Strider 2016년 6월 30일
I have namburs C= (4.6 17.9 4.6 18.5 7.8 1.5 5.9 6.3)
And i hvae two conatat numbers A=4.7 and. B=7.8
And equation is Y=log((A-C)/(C-B)) How can I apply this equation to all the numbers in C? So I can get Y for all of them. Please help

채택된 답변

Star Strider
Star Strider 2016년 6월 30일
You need to ‘vectorise’ it to do element-wise operations by replacing the (/) with (./):
C = [4.6 17.9 4.6 18.5 7.8 1.5 5.9 6.3];
A = 4.7;
B = 7.8;
Y = log((A-C)./(C-B))
You get a complex result in ‘Y’ because some of the numbers are negative. If you don’t want that, add an abs call:
Y = log(abs((A-C)./(C-B)))

추가 답변 (1개)

user1996
user1996 2016년 6월 30일
Thank you very much!

카테고리

Help CenterFile Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by