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 commentaires

Rik
Rik le 1 Déc 2022
The variable name v doesn't actually occur anywhere in your code. What exactly do you want to happen?
arian hoseini
arian hoseini le 3 Déc 2022
sorry i changed that....i want the last P's to be shown in my command window.

Connectez-vous pour commenter.

 Réponse acceptée

Rik
Rik le 3 Déc 2022

0 votes

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.

Plus de réponses (0)

Produits

Version

R2016b

Community Treasure Hunt

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

Start Hunting!

Translated by