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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T22:32:21+00:00 2026-05-29T22:32:21+00:00

Say that I had a matrix of temperature values and a vector corresponding to

  • 0

Say that I had a matrix of temperature values and a vector corresponding to the depth of the measurements, e.g.

depth = [1,4,8,11,15,16,20];
Temp = rand(1800,7);

I would like to insert a row of headings into the first row of Temp, where each heading represents the depth of the measurement. I need the heading to state temp and then the depth e.g. temp1, temp4, temp8, temp11… etc.

I was thinking of doing something like defining ‘temp’ and then adding the corresponding depth of each column, e.g.

varstarter = 'temp';

And then use something like ‘regexp’ but I’m not sure on how this would work.
Any suggestions?

  • 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-29T22:32:22+00:00Added an answer on May 29, 2026 at 10:32 pm
    arrayfun(@(x) ['temp' int2str(x)],depth,'UniformOutput',false)
    

    Here, @(x) ['temp' int2str(x)] defines an anonymous function that appends an integer input as characters to the given character sequence temp. arrayfun then applies this function to every element of the second argument, i.e. depth. (Since arrayfun is most often used to produce numerical output, e.g. one number per application of the function, the output usually is a matrix with size in at least one dimension equal to the second input. The 'UniformOutput',false option thus tells it that this is not the case here (the length of the strings depends on the number of digits of each input), the output needs to be a cell array.)

    Use [ans; num2cell(Temp)]; to combine headings and numerical data into one cell array.

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

Sidebar

Related Questions

Let's say I had a program in C# that did something computationally expensive, like
First off I would like to say that I have done ample research on
Yesterday I had a team leader of another team say that they took a
I had this doubt for sometime now, some people say that there's no such
Say that I have two tables like those: Employers (id, name, .... , deptId).
Let's say that I had an array in the Python backend and wanted to
Say I have an $input array, that contains something like this : array 0
Instinctively, I would say that this is impossible, as NHibernate needs to know some
Returning a datatype. For instance, let's say that I had made a datatype: data
I have an application that uses several different Java classes and would like to

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.