how can i use table after a function?
4 views (last 30 days)
Show older comments
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 Comments
Rik
on 1 Dec 2022
The variable name v doesn't actually occur anywhere in your code. What exactly do you want to happen?
Accepted Answer
Rik
on 3 Dec 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.
0 Comments
More Answers (0)
See Also
Categories
Find more on Tables in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!