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

  • Home
  • SEARCH
  • 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 8565227
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T17:22:40+00:00 2026-06-11T17:22:40+00:00

I am trying to import data files from an oscilloscope into Matlab. It seems

  • 0

I am trying to import data files from an oscilloscope into Matlab. It seems like the scope manufacturer tried to make this task as difficult as possible. Here is what the file looks like: it has three columns, and the values in the last two columns are numbers that might have a letter as suffix for the units (e.g. “m” = milli, “u” = micro, “n” = nano…), but not always, aas you can see in the example.

Right now I am doing something like

data = textscan(fid,'%d%s%s',ns,'Headerlines',1,'Delimiter',',');

where data{1} is a cell array that I can easily convert in to a vector, but data{2} and data{3} are cell arrays of strings. I would like to strip the last character if it is a letter, convert to a vector, and scale each element according to the unit suffix, if there is one.

Here is an excerpt of my file:

No.,Time,CH1
1,-6,0
2,-5.99999,6m
3,-5.99998,0
4,-5.99997,8m
5,-5.99996,-12m
6,-5.99995,6m
...
600006,50u,-4m
600007,60u,-8m
600008,70u,62m
600009,80u,0
600010,90u,70m
600011,100u,-104m
  • 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-11T17:22:41+00:00Added an answer on June 11, 2026 at 5:22 pm

    For the last column, if the values are ALWAYS either 0 or terminate with m you can use regular expressions to strip off the char.

    value = regexprep(input_string, 'm', ''); % replace any m's with nothing
    

    You can wrap this in an anonymous function and apply it to the entire cell array with cellfun

    convertFn = @(x) str2double( regexprep( x, 'm', '') );
    data_column = cellfun(convertFn, data{3}); 
    

    If the terminating char can be some other value you’ll need to apply the solution for the 2nd column which is below.

    Converting the 2nd column is a bit more complicated because you want to alter the value based upon the terminating character.

    You’ll need to write a simple function that strips the char and returns the scaled value.

    function v = convert_str(s)
      if numel(str)==1 && strcmp(s, '0')
         v = 0;
      else 
         v = str2double(s(1:end-1)); % convert all but last char to number
    
         if strcmp( s(end), 'u') )
            v = v * 1e-6;
         end
      end
    end
    

    You can then use this new function in a call to cellfun to convert the second column:

    data_column = cellfun(@convert_str, data{2});
    

    Note: The code above isn’t tested but it illustrates what you need to do.

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

Sidebar

Related Questions

I'm aiming to import data from various folder and text files into matlab. clear
I am trying to import data from excel file (.xlsx) into sql database, my
I’m trying to import fixed width data from text file into SQL Server Express
I sometimes import data from CSV files that were provided to me, into a
I am trying to import an excel file into a data table using GemBox
I am trying to import a csv file to insert data into an existing
I'm trying to import a cython module data.pyx into another cython module user.pyx. Everything
I'm trying to import a csv (that is a data extract from a SQL
Im trying push some data into a CRM system via an XML import. I
I'm trying to import a CSV files into my MySQL table using the following

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.