フィルターのクリア

How to pack value into an vector?

2 ビュー (過去 30 日間)
Jack Nguyen
Jack Nguyen 2019 年 5 月 22 日
編集済み: Rik 2019 年 5 月 22 日
Hi every one.
I have trouble packing values that are calculated into a vector hence what it does when I plot is that it only shows single plot point. Instead of plotting the whole values in pre-define vectors. Thank you in advance for help me out. I'm appreciated.
This is my code:
function run()
persistent gradual_opening_of_tap_file;
%% Set timer on
tmr = timer('ExecutionMode', 'FixedRate', ...
'Period', 1, ...
'TimerFcn', {@timerCallback});
gradual_opening_of_tap_file = fopen('Gradual_opening_of_tap.txt','r'); % Open gradual opening of tap data
start(tmr);
function timerCallback(hObj, eventdata)
fgetl_tap_on_data = fgetl(gradual_opening_of_tap_file);
gradual_opening_of_tap = sscanf(fgetl_tap_on_data,'%f V,%i counts, %i ms');
V_s = 5;
p = 1000;
g = 9.81;
pressure_tap_on = [];
flow_rate_tap_on = [];
head_tap_on = [];
hydraulic_tap_on = [];
p = gradual_opening_of_tap(1);
counts = gradual_opening_of_tap(2);
time = gradual_opening_of_tap(3)/1000;
if ischar(fgetl_tap_on_data)
%% Im not too sure how to pack all these value back into pre-declared varibles for continuous plotting
pressure_tap_on(end+1,:) = (p/V_s - 0.04)/0.0018;
flow_rate_tap_on(end+1,:) = counts /330*(time/1000);
head_tap_on(end+1,:) = pressure_tap_on/(p*g);
hydraulic_tap_on(end+1,:) = flow_rate_tap_on .* pressure_tap_on/1000;
subplot(2,2,3)
plot(time, pressure_tap_on,'ro');
subplot(2,2,4)
plot(time, flow_rate_tap_on, 'ro');
subplot(2,2,2)
plot(flow_rate_tap_on, head_tap_on, 'ro');
subplot(2,2,1)
plot(flow_rate_tap_on, hydraulic_tap_on,'ro');
% set(a , 'XData', time, 'YData', pressure_tap_on)
% set(b , 'XData', time, 'YData', flow_rate_tap_on)
% set(c , 'XData', flow_rate_tap_on, 'YData', head_tap_on)
% set(d , 'XData', flow_rate_tap_on, 'YData', hydraulic_tap_on)
else
stop(tmr)
fclose all;
end
end

回答 (0 件)

カテゴリ

Help Center および File ExchangeAxis Labels についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by