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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T14:54:29+00:00 2026-06-12T14:54:29+00:00

I have a 32×1 struct array . Each element of this array has several

  • 0

I have a 32x1 struct array. Each element of this array has several fields. I am trying to check which elements are empty (done), but then I want to create a vector with all the elements that were not empty.

For example I have the struct array called satdata, from which I want to see if the field SVID is empty, so satdata(i).SVID. SVID should go from 1 through 32 for my different elements. But if there is a missing element, then it can be [1:4 6:10 11:32]. So I want to create a column vector that is (for this case)

[1;2;3;4;6;7;8;9;10;11;12;13;14;15;16;17;18;19...32].

This is what I have so far:

for i = 1:32
    if isempty(satdata(i).SVID)
        continue
    else
    svid = satdata(i).SVID;
     svIdVec(i,:) = svid;
    end
end

Which correctly checks for the empty slots, but when I create the vector I get something that looks like svIdVec = [0,2,3,4...32]. In this case only the first element is empty. Therefore I want to get a 31x1 vector such as [2,3,4...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-12T14:54:30+00:00Added an answer on June 12, 2026 at 2:54 pm

    You don’t need the loop:

    svIdVec = {satdata.SVID};
    [svIdVec{~cellfun(@isempty,svIdVec)}]'; % select only the non-empty values
    

    If the SVID field is a vector and you want to aggregate that in a matrix, the following should be used (above code for scalars cannot be used to handle vectors):

    svIdVec = {satdata.SVID}';
    svid = ~cellfun(@isempty,svIdVec );
    svIdVec = cell2mat(svIdVec(svid));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

have written this little class, which generates a UUID every time an object of
Have a painfully simple blog Post creator, and I'm trying to check if the
I have a php array like this: [ ['url_id' => 2191238, 'time_spent' => 41],
I have a file which is space delimited which looks like this: probeset_id submitted_id
I have a header file in which there is a large struct. I need
I have this string: 525,294,475,215,365,745 and i need to remove 475..and comma. and if
I have a fairly large map consisting of Raphael paths which im trying to
I have an .xml file which has an accompanying .xsl file. The output of
I have an array in php like this : Array ( [0] => Array
I have a UITableView that is being populated from an NSMutable array that has

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.