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 8398703
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T21:07:02+00:00 2026-06-09T21:07:02+00:00

from MATLAB command line , when I type my variable a , it gives

  • 0

from MATLAB command line , when I type my variable a , it gives me values as expected :

a =


            value_1
            value_2

and I would like to access to each value of a, I tried a(1) but this gives me empty
the type of a is 1x49char.
how could I get value_1 and value_2 ?

 whos('a')
  Name      Size            Bytes  Class    Attributes

  a         1x49               98  char 

I get the a from xml file :

<flag ="value">
    <flow>toto</flow>
     <flow>titi</flow>
 </flag>

a+0:

ans =    
    10  32  32   32  32  32  32  32  32  32  32  32  32  98,...
   111 111 108  101  97 110  95  84  10  32  32  32  32  32,...
   32   32  32   32  32  32  32  66  79  79  76  10  32  32,...
   32   32  32   32  32  32  32
  • 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-09T21:07:04+00:00Added an answer on June 9, 2026 at 9:07 pm

    You seem to have an somewhat inconvenient character array. You can convert this array in a more manageable form by doing something like what @Richante said:

    strings = strread(a, '%s', 'delimiter', sprintf('\n'));
    

    Then you can reference to toto and titi by

    >> b = strings{2}
    b = 
    toto
    
    >> c = strings{3}
    c = 
    titi
    

    Note that strings{1} is empty, since a starts with a newline character. Note also that you don’t need a strtrim — that is taken care of by strread already. You can circumvent the initial newlines by doing

    strings = strread(a(2:end), '%s', 'delimiter', sprintf('\n'));
    

    but I’d only do that if the first newline is consistently there for all cases. I’d much rather do

    strings = strread(a, '%s', 'delimiter', sprintf('\n'));
    strings = strings(~cellfun('isempty', strings))
    

    Finally, if you’d rather use textscan instead of strread, you need to do 1 extra step:

    strings = textscan(a, '%s', 'delimiter', sprintf('\n'));
    strings = [strings{1}(2:end)];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm running MATLAB (command line version) from a shell script, and I'd like it
I would like to plot a heatmap on a table imported from MATLAB. The
Is there is easy command in MATLAB which prevents program from crashing when it
It's possible to call .NET from MATLAB, so I thought I would try to
I have a matlab function and I was able to run it from command
i want to run a Matlab from commandline with arguments. Like matlab -r test.m
How is it possible to get, directly from the Matlab command window, the position
I'm working on a command line application for ultrasound simulation in MATLAB. Nearly every
I would like to be able to run a function from the directory where
how can i write this command from mathematica to matlab? total = Apply[Plus, Flatten[mlat]]/L2

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.