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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T22:55:54+00:00 2026-06-01T22:55:54+00:00

I have a structure like so: Basis.FieldsBasisType.fieldsBasisComponents There are ~13 components to each basis,

  • 0

I have a structure like so:

Basis.FieldsBasisType.fieldsBasisComponents

There are ~13 components to each basis, including 6 asset class IDs.

So, for example

fieldnames(Basis.SalaryIncrease) =

'Constant'
'AWeight'
'AAssetClassID'
'ATimeLag'
'BWeight'
'BAssetClassID'
'BTimeLag'
'CWeight'
'CAssetClassID'
'CTimeLag'
'DWeight'
'DAssetClassID'
'DTimeLag'
'EWeight'
'EAssetClassID'
'ETimeLag'
'FWeight'
'FAssetClassID'
'FTimeLag'
'cap'
'floor'

Now what I want to do is select all unique asset classes used in any basis. I am really struggling to make this neat though, currently I am using:

basisNames = fieldnames(Basis);
requiredSeries=[];
for i = 1:size(fieldnames(Basis),1)
    requiredSeries = [requiredSeries;unique(Basis.(basisNames{i}).AAssetClassID)];
    requiredSeries = [requiredSeries;unique(Basis.(basisNames{i}).BAssetClassID)];
    requiredSeries = [requiredSeries;unique(Basis.(basisNames{i}).CAssetClassID)];
    requiredSeries = [requiredSeries;unique(Basis.(basisNames{i}).DAssetClassID)];
    requiredSeries = [requiredSeries;unique(Basis.(basisNames{i}).EAssetClassID)];
    requiredSeries = [requiredSeries;unique(Basis.(basisNames{i}).FAssetClassID)];
end
requiredSeries = unique(requiredSeries)

Which is really ugly in my opinion. I want to do some kind of string compare to find ‘AssetClassID’ within the fields, so something like:

field = fieldnames(Basis.(basisNames{1}));
strfind(field,'AssetClassID');

And then use that cell array to logically index ‘field’ and just grab the data from ‘AssetClassID’ fields. But I am stuck on making that work.

~cellfun('isempty',strfind(field,'AssetClassID')) 

gets me the logical index, how do I apply that to fields and then use it to get values.

Any ideas would be appreciated, I feel there should be a neat way of doing it and I am missing something. Hardcoding those fieldnames seems short sighted as a solution.

#

Edit: I hate myself.

Sorry folks, I came up with a working variant like moments after posting this, apologies for wasting anyones time!

basisNames = fieldnames(Basis);
for i = 1:size(fieldnames(Basis),1)
    field = fieldnames(Basis.(basisNames{i}));
    field = cell2mat(field(~cellfun('isempty',strfind(field,'AssetClassID'))));
    for j = 1:size(field,1)
        requiredSeries = [requiredSeries;unique(Basis.(basisNames{i}).(field(1,:)))];
    end
    requiredSeries = unique(requiredSeries)
end

I was missing a necessary cell2mat earlier which caused the inability to get it to bloody work. Anyway, I’d always like to hear improvements to that but otherwise you can shut this down.

  • 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-01T22:55:55+00:00Added an answer on June 1, 2026 at 10:55 pm

    Sorry folks, I came up with a working variant 30 mins or after posting this, popping it down as an answer as per Michelle’s suggestion.

    basisNames = fieldnames(Basis);
    for i = 1:size(fieldnames(Basis),1)
        field = fieldnames(Basis.(basisNames{i}));
        field = cell2mat(field(~cellfun('isempty',strfind(field,'AssetClassID'))));
        for j = 1:size(field,1)
            requiredSeries = [requiredSeries;unique(Basis.(basisNames{i}).(a(1,:)))];
        end
        requiredSeries = unique(requiredSeries)
    end
    

    I was missing a necessary cell2mat earlier which caused the inability to get it to bloody work. Anyway, I’d always like to hear improvements to that but otherwise you ignore this entirely 🙂

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

Sidebar

Related Questions

i have structure like below, <div class=btheme> <a href=/a1><img src=/a1.jpg /></a> <div class=caption> <div>image
I have html structure like below: <div id=banner-menu-holder> <div> <div class=avalible> <div class=items-holder> <div>
I have a structure like: <div id=holder> <div id=first></div> <div class=box>I'm the first</div> <div
I have code structure like that: var adjective = context.Adjectives.Find(11); //works var substantive =
I have a structure like this: A contains collection of B (mapped as not-lazy)
I have a structure like this.... UITableViewController -> UITableViewCell -> UIView I need the
I have a structure like the following: <form> <input type=text /> <input type=text />
I have xml structure like this: <Group id=2 name=Third parentid=0 /> <Group id=6 name=Five
I have directory structure like so: |-- ROOT |-- Project1 | |-- application |
So I have a structure like this: Widget: Component 1: Component 2: Component 3:

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.