Mahesh - when I run your attached code, I observe errors with
if (out==1)
newdateTime1=newdateTime;
temperature=[newdateTime1 temp];
humidity=[newdateTime1 humi];
else
pressure=[newdateTime press];
end
because temp, humi, and press are not defined
Undefined function or variable "temp".
Please correct the code and confirm that you wish to create a variable that tracks the time and temperature, humidity, and pressure for all input (lines). If that is the case, then you could do something like
temperatureData = [];
humidityData = [];
pressureData = [];
fid = fopen('testdata.txt');
while ~iseof(fid)
collected=fgets(fid);
temperatureData = [temperatureData ; [newdateTime t1 t2]];
end
fclose(fid);
Best Answer