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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T19:40:30+00:00 2026-06-03T19:40:30+00:00

Possible Duplicate: how to compare array with matlab Here’s an example of what I’m

  • 0

Possible Duplicate:
how to compare array with matlab

Here’s an example of what I’m looking for:

[a,b,c,d] = getVal(x);

This will give:

a =
    a

b=
    0

c =
    10

d =
    []   

And I have:

expected = {'a','0','10',[]};

How could I make the comparison between [a,b,c,d] and expected ?
When I call only getVal(x), it gives me only the first value and when I write:

[a,b,c,d] = getVal(x)

Then I got all values in the log. Why isn’t this the case when I call
getVal(x)?
For comparison I tried:

isequal([a,b,c,d], expected {1:end})

but it doesn’t work, any idea how to solve my problem?

  • 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-03T19:40:31+00:00Added an answer on June 3, 2026 at 7:40 pm

    Don’t try to put a, b, c, d into a matrix. That would append spaces. Instead, use a cell array, just like you have for expected:

    >> a='a'; b='0'; c='10'; d=[];
    >> expected = {'a','0','10',[]};
    >> isequaln({a,b,c,d}, expected)
    
    ans =
    
         1
    

    You also asked why simply calling getVal(x) doesn’t give all the values. That is because in MATLAB, a function can (and often does) react to the number of output parameters, i.e., the number of variables on the left hand side of the assignment. Your getVal function returns four values if called with four output parameters; If it doesn’t do anything special, then calling it with zero or one output parameter will return only the first of these values, in your example, 'a'. If you want a cell array with all four of these values, do something like

    [a, b, c, d] = getVal(x)
    {a, b, c, d}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: PHP compare array I have to compare two arrays in php and
Possible Duplicate: A better way to compare Strings which could be null I have
Possible Duplicate: How can I compare (directory) paths in C#? I have a filename
Possible Duplicate: How to compare strings? ( == returns wrong value) I have the
Possible Duplicate: php date compare I have a date that I take from the
Possible Duplicate: How do I compare a raw time in Java? For example suppose
Possible Duplicate: Octave/MATLAB: How to compare structs for equality? is there a simple comparison
Possible Duplicate: Compare 2 dates with JavaScript I would like to have a Javascript
Possible Duplicate: Using jQuery to compare two arrays I have to send the form
Possible Duplicate: How to compare two arraylist? I have two String ArrayLists of different

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.