I want to set time when i plot graph (in gui)
이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
이전 댓글 표시
when i put
09:12:45 ->Edit text 1
12:00:12 ->Edit text 2
i want to plot graph between text 1 and text 2 time
is it possible?
at first i imported data from excel
채택된 답변
Walter Roberson
2018년 8월 17일
If you do not use a timetable() object, then you can use standard logical masks, like
start_dur = duration( get(handles.text1, 'String') );
end_dur = duration( get(handles.text2, 'String') );
dur_column = YourArray{:,3}; %select appropriate duration column, method will vary according to how you stored your data
mask = dur_column >= start_dur & dur_column <= end_dur;
selected_data = YourArray{mask, :}; %method will vary according to how you stored your data
Now you can plot from selected_data
댓글 수: 13
what is Yourarray{:,3}??? 3 mean?
I had to guess about how you were storing your data. One of the ways that permits data of different types to be represented is to use table() objects. When you use a table() object named YourArray, then the syntax YourArray{:,3} would mean that you wanted to extract the contents of column 3 of YourArray. Here the 3 was chosen arbitrarily for illustration purposes, as I do not know how your data is arranged.
If you are using a cell array instead of a table, then if each cell contains a single duration, then you would instead use a syntax such as
dur_column = cell2mat(YourArray(:,3));
or, equivalently (and more efficiently)
dur_column = vertcat(YourArray{:,3});
When you use a cell array, YourArray{5,3} would mean to extract the content stored at cell row 5 column 3; the content itself might be any size or data type.
woongki park
2018년 8월 17일
편집: woongki park
2018년 8월 17일
handles.fileName=uigetfile('*.xls');
fileName=handles.fileName;
[~,txt,~]=xlsread(fileName,'C27:C30000');
[Ch1,~,~]=xlsread(fileName,'E27:E30000');
[Ch2,~,~]=xlsread(fileName,'F27:F30000');
[Ch3,~,~]=xlsread(fileName,'G27:G30000');
[Ch4,~,~]=xlsread(fileName,'H27:H30000');
[Ch5,~,~]=xlsread(fileName,'I27:I30000');
[Ch6,~,~]=xlsread(fileName,'J27:J30000');
[Ch7,~,~]=xlsread(fileName,'K27:K30000');
[Ch8,~,~]=xlsread(fileName,'L27:L30000');
[Ch9,~,~]=xlsread(fileName,'M27:M30000');
[Ch10,~,~]=xlsread(fileName,'N27:N30000');
[Ch11,~,~]=xlsread(fileName,'O27:O30000');
[Ch12,~,~]=xlsread(fileName,'P27:P30000');
[Ch13,~,~]=xlsread(fileName,'Q27:Q30000');
[Ch14,~,~]=xlsread(fileName,'R27:R30000');
[Ch15,~,~]=xlsread(fileName,'S27:S30000');
[Ch16,~,~]=xlsread(fileName,'T27:T30000');
[Ch17,~,~]=xlsread(fileName,'U27:U30000');
[Ch18,~,~]=xlsread(fileName,'V27:V30000');
[Ch19,~,~]=xlsread(fileName,'W27:W30000');
[Ch20,~,~]=xlsread(fileName,'X27:X30000');char(txt); %txt is time DateNumber=datenum(txt); Date=datetime(DateNumber,'ConvertFrom', 'excel'); Date1=datetime(Date,'Format','hh:mm:ss');
i use datetime type
I am having to guess here about what is stored in column C, as your code is a bit contradictory.
handles.fileName=uigetfile('*.xls');
fileName=handles.fileName;
[~,txt,~]=xlsread(fileName,'C27:C30000');
Ch = xlsread(fileName,'E27:X30000');
Date1 = duration(txt, 'InputFormat', 'hh:mm:ss', 'Format', 'hh:mm:ss');
start_dur = duration( get(handles.text1, 'String') );
end_dur = duration( get(handles.text2, 'String') );
mask = Date1 >= start_dur & Date1 <= end_dur;
selected_Ch = Ch(mask, :);
woongki park
2018년 8월 17일
편집: woongki park
2018년 8월 17일
09:02:50
09:02:52
09:02:54
09:02:56
this is in column C . it's like hh:mm:ss format. and i will plot each channel in one figure. and i'll use check box .and then i can select channel that i want to see or not
Then the code I posted will probably work.
You can access the channels as selected_Ch(:, CHANNEL_NUMBER)
ok i'll try and if it doesnt'work i'll ask u again
woongki park
2018년 8월 17일
편집: woongki park
2018년 8월 17일
it doesn't work .duration line error occurr . error message: input data should be 3 columns numeric arrays i think 09:12:24 is just string format (like text)
Which release are you using? If I recall correction, duration() was improved as of R2018a.
2016 version
Change
Date1 = duration(txt, 'InputFormat', 'hh:mm:ss', 'Format', 'hh:mm:ss');
start_dur = duration( get(handles.text1, 'String') );
end_dur = duration( get(handles.text2, 'String') );
to
Date1 = datetime(txt, 'InputFormat', 'hh:mm:ss', 'Format', 'hh:mm:ss');
start_dur = duration( get(handles.text1, 'String') );
end_dur = duration( get(handles.text2, 'String') );
Date1 = Date1 - dateshift(Date1, 'start', 'day');
start_dur = start_dur - dateshift(start_dur, 'start', 'day');
end_dur = end_dur - dateshift(end_dur, 'start', 'day');
woongki park
2018년 8월 18일
편집: woongki park
2018년 8월 18일
it doesn't work.duration function still have problem. dateshift are not working with duration function
how about using datetime instead of duration
Date1 = datetime(txt, 'InputFormat', 'hh:mm:ss', 'Format', 'hh:mm:ss');
start_dur = datetime( get(handles.text1, 'String') );
end_dur = datetime( get(handles.text2, 'String') );
Date1 = Date1 - dateshift(Date1, 'start', 'day');
start_dur = start_dur - dateshift(start_dur, 'start', 'day');
end_dur = end_dur - dateshift(end_dur, 'start', 'day');
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기
태그
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
