how can i use table after a function?

3 visualizaciones (últimos 30 días)
arian hoseini
arian hoseini el 1 de Dic. de 2022
Respondida: Rik el 3 de Dic. de 2022
how can i use a table in this function?
T=table(P','VariableNames',{'Power'});
disp(T);
disp('Arian');
clear all
clc
L0 = 6.0;
L = fzero(@fun,L0) %show the final Lambda
function res = fun(L)
B = [7.20; 7.85; 7.98; 7.10; 7.30; 6.90; 8.01; 7.30; 7.42; 7.16];
C = [0.00142; 0.00194; 0.00482; 0.00321; 0.00210; 0.00178; 0.00212; 0.00350; 0.00267; 0.00390];
D = [0.0000001; 0.0000002; 0.0000003; 0.0000001; 0.0000002; 0.0000003; 0.0000001; 0.0000002; 0.0000003; 0.0000001];
Pmin =[150; 100; 50; 50; 100; 100; 100; 100; 100; 100];
Pmax =[600; 400; 200; 200; 350; 500; 300; 300; 300; 300];
Pr = 2500;
c=B-L;
b=2*C;
a=3*D;
delta=b.^2-(4*a.*c);
P=(-b+sqrt(delta))./(2*a);
P(P<Pmin) = Pmin(P<Pmin);
P(P>Pmax) = Pmax(P>Pmax);
Pt=sum(P);
res=Pr-Pt;
end
  2 comentarios
Rik
Rik el 1 de Dic. de 2022
The variable name v doesn't actually occur anywhere in your code. What exactly do you want to happen?
arian hoseini
arian hoseini el 3 de Dic. de 2022
sorry i changed that....i want the last P's to be shown in my command window.

Iniciar sesión para comentar.

Respuesta aceptada

Rik
Rik el 3 de Dic. de 2022
You can make P a second output of your function. That way you can call it with the final value of L and extract what you want.
If that doesn't solve your problem you will have to explain in more detail what exactly you want to happen.

Más respuestas (0)

Categorías

Más información sobre Logical en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2016b

Community Treasure Hunt

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

Start Hunting!

Translated by