Result in complex

1 Ansicht (letzte 30 Tage)
Ayda
Ayda am 26 Dez. 2011
Good morning/evening I wrote this code but the result was in complex form Can any one help to convert the result into real numbers
clc
disp('Enter the required information for the fisrt alternative ')
IntialCostFA=input('Enter the intial cost for the first alternative : ');
UACFA=input('Enter the uniform annual cost for the first alternative : ');
UABFA=input('Enter the uniform annual benefit for the first alternative : ');
SalFA=input('Enter the salvage value for the first alternative : ');
UseLifeFA=input('Enter the useful life for the first alternative : ');
disp('Enter the required information for the second alternative ')
IntialCostSA=input('Enter the intial cost for the second alternative : ');
UACSA=input('Enter the uniform annual cost for the second alternative : ');
UABSA=input('Enter the uniform annual benefit for the second alternative : ');
SalFSA=input('Enter the salvage value for the second alternative : ');
UseLifeSA=input('Enter the useful life for the second alternative : ');
r=input('Enter the MARR: ');
n1=UseLifeFA;
n2=UseLifeSA;
% NPW for Alt A
a=(((1+r)^n2)-1)/(r*((1+r)^n2));
CapRec1=UACFA*a;
PR1=(IntialCostFA-SalFA)*(1+r)^n1;
PWC1=IntialCostFA+CapRec1+PR1;
CapRec2=UABFA*a;
PR2=SalFA*(1+r)^n2;
PWB1=CapRec2+PR2
  1 Kommentar
Walter Roberson
Walter Roberson am 26 Dez. 2011
What does "MARR" mean in this context?
Can the MARR be negative?
Are all of the inputs scalars, or is it possible that the MARR is a vector?
Note: "a" could also be rewritten as (1-1/(1+r)^n2)/r
For efficiency, it would make sense to only calculate (1+r)^n2 once, assign that to a variable, and use that in the other expressions.
Have you put a breakpoint in at the assignment to n1, and single-stepped through the lines until you found the one that generates the complex value? If so, then which line is it?

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Particle & Nuclear Physics finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by