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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T06:17:57+00:00 2026-05-31T06:17:57+00:00

Hey so I have a bash command that echos a string based on reading

  • 0

Hey so I have a bash command that echos a string based on reading some file. Say for simplicity it is like this

for line in `cat file`
do
if [ "$line" == "IwantThisLine" ]
then   
echo "True"
fi
done

And I have it saved as its own individual script. Its called readRef.sh. So now I want to call it in matlab and store whatever it outputs in a variable! I am not entirely sure on how to do that, I seem to get an error when using evalc() on a system(). But it could be just me messing up quotations.

I tried something like

evalc(system(['./readRef.sh ' bamfile']))

The “bamfile” is a variable that is just a string to the path of a bamfile.

I get this error.

>> tes = evalc(system(['./readRef.sh ' smplBamFile])) 
hg18 
??? Undefined function or method 'evalc' for input arguments of type 'double'.

Coincidentally it does spit out “hg18” which is what I want to set the matlab variable to be.

  • 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-05-31T06:17:58+00:00Added an answer on May 31, 2026 at 6:17 am

    Oh, I see. I don’t think you need evalc at all. Reading the system docs you can just do:

    [status, result] = system('echo True; echo "I got a loverly bunch of coconuts"')
    

    And result will be

    True
    I got a loverly bunch of coconuts
    

    So just do:

     [status, result] = system(['./readRef.sh ' smplBamFile])
    

    The reason evalc isn’t working is that it requires its input to be a Matlab expression in a string, but you are passing it the result of system.

    You could try:

     evalc("system(['./readRef.sh ' smplBamFile])")
    

    See how I’m passing in the system(...) as a string?

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

Sidebar

Related Questions

Hey I have this kinda structure in my ini file I want to be
Hey I have an XML file and I would like to navigate to a
Hey I have seen sites that instead of an int show you a string.
Hey i have this div that shows as a popup: <div class=popup> </div> Then
Hey all i have an XML file that i am trying to loop though.
Hey, I have bash script running a wget command to get a directory: wget
Hey I have this configuration in my web.config <log4net> <appender name=LogFileAppender type=log4net.Appender.FileAppender> <param name=File
Hey I have this code right here: http://pastie.org/534470 And on line 109 I get
Hey I have a really annoying IE7 bug that I am trying to work
Hey I have this code but it doesn't work because it is expecting a

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.