フィルターのクリア

Info

この質問は閉じられています。 編集または回答するには再度開いてください。

insert times file as a matrix

1 回表示 (過去 30 日間)
Ahmed Nabil
Ahmed Nabil 2017 年 9 月 21 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
Hello, I have the following time file and I want to put the values into a matrix to plot it with another variable.
I tried to use this function,
T=load('time.txt','-ascii');
but Matlab load only the hours' values, I want to consider the minutes' values also.

回答 (3 件)

KSSV
KSSV 2017 年 9 月 21 日
Use textscan read about it.
  1 件のコメント
Ahmed Nabil
Ahmed Nabil 2017 年 9 月 21 日
tried to use the following functions,
fileID = fopen('Uz10.txt');
Uz10=textscan(fileID,'%d');
but gives weird solution like the picture, I want it as a matrix 109x1

Ahmed Nabil
Ahmed Nabil 2017 年 9 月 25 日
I used 'textscan' but all goes to the first cell only,
tried to use this code,
Uz10t2=Uz10t1{1}; %to extract the first cell into a matrix
Uz10=cell2mat(Uz10t2);
got this error,
Dimensions of matrices being concatenated are not consistent.

Walter Roberson
Walter Roberson 2017 年 9 月 25 日
fileID = fopen('Uz10.txt');
Uz10_cell = textscan(fileID,'%{HH:MM}D');
fclose(fileID);
Uz10 = timeofday(Uz10_cell{1});
This will give you a "duration" object. Duration objects can be used as the x axis values from roughly R2015b onwards.

この質問は閉じられています。

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by