Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8298637
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T15:51:10+00:00 2026-06-08T15:51:10+00:00

I still can not create something usable in matlab. The task is pretty simple.

  • 0

I still can not create something usable in matlab.

The task is pretty simple. I have two files: devideHistory.log deals.log In both files lets consider only first two column. So first file contains X and Y which should form graphic. Second file contains X and Y of markers that should be displayed on the graphic. With help of this community such program was created

clear

fDevide = fopen('devideHistory.log');
data = textscan(fDevide, '%f:%f:%f:%f %f,%f %f,%f');
fclose(fDevide);

% hh:min:sec:millisec
secvec = [60*60 60 1 1e-3];
x = [data{1:4}] * secvec';

flvec = [1 1e-16];
y = [data{5:6}] * flvec';

xindays = x / (24*60*60);

plot(xindays, y);
% set(gca, 'YTickLabel', get(gca,'YTick'))
% datetick('x', 'HH:MM:SS');

hold on

fDeals = fopen('deals.log');
data = textscan(fDeals, '%f:%f:%f:%f %f,%f %f,%f %f,%f %f');
fclose(fDeals);

% hh:min:sec:millisec
secvec = [60*60 60 1 1e-3];
x = [data{1:4}] * secvec';

flvec = [1 1e-16];
y = [data{5:6}] * flvec';

xindays = x / (24*60*60);

plot(xindays, y, 'go','MarkerSize',6,'LineWidth',3);

% i need to set enough precision on Y but this doesn't work because
% while zooming labels doesn't update
set(gca, 'YTickLabel', get(gca,'YTick')) 

% i want to have "time" on X but this doesn't work because
% while zooming new labels doesn't appear
datetick('x', 'HH:MM:SS');

Result:
graphic

But I have two problems with zooming feature:

  • while zooming in labels from X disappear and as a result there are not labels at X at all how to always display "labels" on axis X
  • while zooming labels on Y is not updated as a result markers are displayed on the wrong position why while zooming marker changes position?

Well my task is pretty simple and straightforward. Are there simple and straightforward solution in matlab for it? Code above already contains several “hacks” and still doesn’t work as expected. I’m afraid contining hacking it doesn’t make sense. Could someone suggest another approach? Probably matlab just not suitable for my needs?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T15:51:17+00:00Added an answer on June 8, 2026 at 3:51 pm
    1. Download http://www.mathworks.com/matlabcentral/fileexchange/36254-ticklabelformat
    2. Remove your own tick labeling calls, these ones:

      set(gca, 'YTickLabel', get(gca,'YTick')) 
      datetick('x', 'HH:MM:SS');
      
    3. Replace them with

      ticklabelformat(gca,'y','%g')
      ticklabelformat(gca,'x',{@tick2datestr,'x','HH:MM:SS'})
      
    4. Make a new helper function tick2datestr.m containing:

      function tick2datestr(hProp,eventData,axName,dateformat)    %#ok<INUSL>
          hAxes = eventData.AffectedObject;
          tickValues = get(hAxes,[axName 'Tick']);
          tickLabels = arrayfun(@(x)datestr(x,dateformat),tickValues,'UniformOutput',false);
          set(hAxes,[axName 'TickLabel'],tickLabels);
      end
      

    most of this helper function is btw copied straight out of ticklabelformat.

    Yes, you can consider this as hacking, but as long as TheMathworks doesn’t implement your desired ‘straightforward’ solution, you have to create your own functionality.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This should be pretty simple, still I can not see what/how something could be
It's very strange because phpmyadmin is not in document root, but still can visit
I have an odd question. Let's assume I create something using scaffolding. This should
I want to create a simple Messaging System on my LAMP site. Not an
I have repaired .net 4.0 but (still) cannot find: Ilasm.exe Any ideas? I need
I have searched all morning and yesterday afternoon and still cannot find an solution
I have a borderless Windows Forms application. The main window creates other forms (simple
I have a simple class called Job with a public ctor and public function
I am working one something and I can't get it to work. I am
I've been working on this for 2 days and still I do not manage

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.