Result in complex

1 visualización (últimos 30 días)
Ayda
Ayda el 26 de Dic. de 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 comentario
Walter Roberson
Walter Roberson el 26 de Dic. de 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?

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Particle & Nuclear Physics en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by