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

The Archive Base Latest Questions

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

i have a file, filedata.mat, containing a 1×1 struct with sub-levels that contain data

  • 0

i have a file, filedata.mat, containing a 1×1 struct with sub-levels that contain data from vehicle channels. the file has close to 30 measured channels. channel names, channel units and channel values (against time) are stored in separate sublevels.

i want to specify which channels (i.e. which columns of data) by column number and have the code place the data in a matrix complete with channel names in row 1 and channel units in row 2.

The code i currently have is below:

clear all;

channels = [1 4 8];

source = load('filedata.mat');

N = size(channels,2);
I = size(source.Data.DataOut,1) + 2;
data = zeros(I,N);

for i = (1:1:I)
    for n = (1:1:N)
        if i == 1
           data(i,n) = source.Data.ChannelNames{channels(n)};
        elseif i == 2
           data(i,n) = source.Data.ChannelUnits{channels(n)};
        else
           data(i,n) = source.Data.DataOut{i,channels(n)};
        end
    end
end

My thinking is that this will place channelnames in row 1 (i.e. when i = 1), channelunits in row 2 (when i = 2) and will then place all remaining rows of data up to i = I.

However when i run this code i get the error “Subscripted assignment dimension mismatch.” on row 14 which is:

 data(i,n) = source.Data.ChannelNames{channels(n)};

if anyone can suggest a solution and – perhaps more importantly – explain where ive gone wrong (so i can learn something!) i would really appreciate it.

Thanks in advance.

  • 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-31T19:57:38+00:00Added an answer on May 31, 2026 at 7:57 pm

    I assume your ChannelNames are cell array of strings. So the statement source.Data.ChannelNames{channels(n)} returns a string that cannot be assigned to a numeric value in data.

    If you want to select channel names and keep them in a variable, make this variable a cell array. Then

    data = cell(I,N);
    data(1,:) = source.Data.ChannelNames(channels);
    data(2,:) = source.Data.ChannelUnits(channels);
    data(3:I,:) = num2cell(source.Data.DataOut(:,channels));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a file data.base which looks like: 1234 XXXX 4321 XXXX 9884 ZZZZ
In the filesystem I have /file.aspx /directory/default.aspx I want to configure IIS so that
I have a variable in code that can have file path or url as
I have a file in the following format: Data Data Data [Start] Data I
I have this file sharing program, where i can get mye files from a
How to check that my params['Filedata'] is corrupted or not? I have function it's
I have this problem: I am choosing a file from JFileChooser and if i
I have the following basic code to read a text file from a StreamReader:
I have an Upload File form, the file has (Name nvarchar, FileData varbinary(max)) Name
I have a class that is currently in a .lib file: class __declspec(dllexport) ReportData

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.