Why isn't my loop working?
1 次查看(过去 30 天)
显示 更早的评论
fid = uigetfile('*.*');
fid = fopen(fid);
deltat = 0.5;
n = 1;
while fgetl(fid)~= -1
line = fgetl(fid);
line = sscanf(line, '%f V, %i counts, %i ms');
vout = line(1);
counts = line(2);
t = line(3)/1000;
t(n+1) = t(n) + deltat;
% Q = flowrate (L/s)
% h = head(m)
% P = pressure
% p = density of water
p = 1000; %kg/m^3);
g = 9.81;
vs = 5;
% vout - get from data
% h - get from data
% Q - calculated from data
P = ((vout/vs) - 0.04)/0.0018;
% Finding head
h = (P/1000)/(p*g);
Q = counts/((t(n)/1000)*330);
% Finding hydraulic power
H =(Q*p*g*h)/1000;
end
6 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Simscape Electrical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!