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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T10:40:22+00:00 2026-05-15T10:40:22+00:00

I am writing a cell array of string into Excel from Matlab. I have

  • 0

I am writing a cell array of string into Excel from Matlab. I have a cell array data{} that I am trying to write into Matlab. It should writting three large lengths of strings to excel since the strcmp passes 3 times. Currently it is only writing the last set of strings into excel. data = { {1×25} {1×35} {1×20} } looks like this. Also I would like to be able to write the data into three cells instead of getting copyied into as many cells as there are lines in the element of the cell array. Is this possible to do with Matlab to excel?

done = {}

for i = 1:3
   q = strcmp(x_gene_ID{i},locus_tags{i});
   if q ==1
       done{end+1} = data{i};
       disp(done);

   end


end


w = xlswrite('data.xlsx',done','E2:E400');

Ok that helps I am aware the cell array’s are larger than 3 cell range. I am trying to get the Nx1 cell array to fit into one cell in Excel because It needs to correspond to information in an adjacent cell. Is this at all possible to do?

A     B      C        D                   E  
w   Rv0146  na  Rv0039c (i want the cell array1 to go here)
s   Rv0156  na  Rv0029c (i want the cell array2 to go here)
s   Rv0156  na  Rv0029c (i want the cell array2 to go here)

Here is what I am looking to do in excel

  • 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-15T10:40:23+00:00Added an answer on May 15, 2026 at 10:40 am

    UPDATED ANSWER:

    If I understand correctly, it appears that your variable data is a cell array where each cell contains a 1-by-N (or perhaps N-by-1) cell array of strings. If you want to try and fit each of these cell arrays of strings into one cell of a spreadsheet, you are going to need to format each into a single long string first.

    Here’s an example of how you could format the cell arrays of strings by concatenating them together with a newline between them:

    data = {{'hello' 'hi' 'hey'} ...              %# Sample cell array of 1-by-N
            {'world' 'earth' 'everyone'} ...      %#   cell arrays of strings
            {'blah' 'blah'}};
    data = cellfun(@(x) {strcat(x,{char(10)})},data);  %# Add newline characters
                                                       %#   to the string ends
    data = cellfun(@(x) {deblank([x{:}])},data);  %# Concatenate the inner cells and
                                                  %#   remove the trailing newlines 
    

    Now that each cell array of strings is just a single long string, each string can be written to a cell of an Excel spreadsheet as follows:

    xlswrite('data.xls',data(:),'Sheet1','E2');  %# Write the data to cells E2 to E4
    

    And here’s what the resulting spreadsheet looks like:

    alt text

    If you use a space ' ' instead of a newline character, here’s what the spreadsheet looks like (after adjusting the row and column widths):

    alt text

    Functions used in the above code: CELLFUN, STRCAT, CHAR, DEBLANK, XLSWRITE.

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

Sidebar

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.