Filter löschen
Filter löschen

How can I apply equation to all data in column?

9 Ansichten (letzte 30 Tage)
user1996
user1996 am 30 Jun. 2016
Kommentiert: Star Strider am 30 Jun. 2016
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

Akzeptierte Antwort

Star Strider
Star Strider am 30 Jun. 2016
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)))

Weitere Antworten (1)

user1996
user1996 am 30 Jun. 2016
Thank you very much!

Kategorien

Mehr zu Get Started with MATLAB finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by