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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T10:21:12+00:00 2026-05-31T10:21:12+00:00

In order to make this question easier to describe I have provided the following

  • 0

In order to make this question easier to describe I have provided the following example code, which is similar to the actual data I am working with:

clear all
AirT = {rand(32,1),rand(32,1),rand(32,1),rand(32,1)};
SolRad = {rand(32,1),rand(32,1),rand(32,1),rand(32,1)};
Rain = {rand(32,1),rand(32,1),rand(32,1),rand(32,1)};
Location = {'England','Wales','Scotland','Ireland'};
points = {'old','old','old','new'};
CorrVariables = {'AirT','SolRad','Rain'};
for i = 1:length(Location);
    Data = @(location) struct('Location',location,CorrVariables{1},AirT{i},...
        CorrVariables{2},SolRad{i},CorrVariables{3},Rain{i});
    D(i) = Data(Location{i});
end
FieldName = {D.Location};
R = corrcoef([D.AirT],'rows','pairwise');
R_Value = [Location(nchoosek(1:size(R,1),2)) num2cell(nonzeros(tril(R,-1)))];
q = points(nchoosek(1:size(R,1),2));
    %to calculate the combination of these points we need to convert the
    %cell into a matrix.
Re = [R_Value q];

From this example I would like to create another cell array in column 5 of Re which is dependant on the strings in columns 4 and 5. So, if columns 4 and 5 in Re are equal, such as ‘old”old’ then column 6 should show ‘old’. However, if the cells differ e.g. ‘old’ ‘new’ then I would like the new cell array (i.e. column 6 in Re) to state ‘old/new’.

How would this be possible?

  • 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-31T10:21:13+00:00Added an answer on May 31, 2026 at 10:21 am

    From your description I think the clearest approach is to use a combination of string concatenation and regular expressions.

    First combine columns 4 and 5 into a new column:

    newColumn = strcat(Re(:,4), '/', Re(:,5));
    

    Now look for the repeated pattern and replace with the first token matched:

    newColumn = regexprep(newColumn, '(\w+)/\1', '$1');
    

    Combine into existing cell matrix:

    Re = [Re, newColumn];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using an approach for this thread in order to make gallery change one
I wanted to make a post request in this website: http://www.prezup.info/index.php?page=films in order to
in order to make things easier for users i want to add multiple keyword
in order to make sure all form submission and all data submitted to server
I realize that this question might not make sense to some, but I was
I have this problem i cant workaround. I cache data in serialized format in
I've tried to put this in generic terms to make it easier to understand.
This question is close to what I'm interested in, but not quite. I have
Consider the following x86 code example: #include <stdlib.h> static int i; static inline __attribute__((always_inline))
This is a question for a WSS/SharePoint guru. Consider this scenario: I have an

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.