How do I get the latest data ^^
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
Hi
We use the sm 130 which is fbg sensor, and our project object is to show how sensor works in 2D
so we use program that is from labview. with it, we can get a wavelength data continously.
we want to make sensor that moves continously
We want to know how to get the latest data from streaming text.
Upload text file is the file we got from the steraming files,
% assume that you are running code in folder your file exists
% open the file
fid = fopen('147');
if fid>0
% loop until end of file is reached
while ~feof(fid)
% read the current line
line = fgetl(fid);
disp(line(25:33))
% extract data from the line
% plot the data
% wait two seconds until continuing with next line
pause(0.1);
end
% close the file
fclose(fid);
end
That code is once we write down.
But we want to get the lastest data like 1540.6710, 1550.0917 (two data)
And we use the lastest data at a, b under the code.
timesToRun = 100;
duration = 1;
tPause(timesToRun) = 0; % pre-allocate
for idx = 1 : timesToRun
tic
>> a=2*10^-6;
>> b=3*10^-6;
>> c=1.2*10^-6;
>> d=2.2*10^-6;
>> e=(a-c)/2;
>> f=(b-d)/2;
>> g=669.77442*e;
>> h=665.1501244*f;
>> i=9.8765*g*(10^-6)-2.959025*h*10^-4;
>> j=-5.185167*g*(10^-3)+0.110963*h;
>> k=0.9999975*g-9.9866625*h;
>> x=[0:1:150]
>> y=(i*x.^4)+(j*x.^3)+(k*x.^2);
>> plot(x,y);
pause(duration); % Note: pause() accepts [Secs] duration
tPause(idx) = abs(toc-duration);
end
and the rest (c,d) is what we will use another streaming data
with these codes, we want to show plot working continously
Please help us how to code for finding the last data.
3 Commenti
Walter Roberson
il 24 Nov 2018
Put a breakpoint in at the statement
line = fgetl(fid);
and execute your code. When it stops,
disp(line)
and show us the result.
Risposte (0)
Vedere anche
Categorie
Scopri di più su Data Type Conversion in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!