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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:05:03+00:00 2026-05-26T15:05:03+00:00

I currently have a function which I am batch running. It outputs its results

  • 0

I currently have a function which I am batch running. It outputs its results to a cell array. I would like to export each of the outputs from the cell array to their own variable.

As such I have a variable id which records the ID of each layer. This process is possible manually as follows:

>> output = 

[300x300x2 double]    [300x300x2 double]    [300x300x2 double]

>> [a1,a2,a3]=deal(output{:});

Where the number after a represents the ID. Is it possible to automate this command, so that the prefix (in this case: a) can be set by the user and the id filled in automatically? As in, I could have variables set as below, and use these in the deal command to name my new variables?

>> id =

 1     2     3

>> prefix =

a

Any ideas?
Thanks.

  • 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-26T15:05:03+00:00Added an answer on May 26, 2026 at 3:05 pm

    You can construct your own custom expression as a string and then evaluate it with eval() (or evalin() if it’s in a function and you want to return the output to your workspace).

    function deal_output(output, id, prefix)
    
    id     = id(:);
    vars   = strcat(prefix, cellstr(num2str(id)))';
    myexpr = ['[', sprintf('%s,', vars{1:end-1}), vars{end}, '] = deal(output{:})'];
    
    evalin('caller', myexpr)
    
    >> output = num2cell(1:3);
    >> id     = 1:3;
    >> prefix = 'a';
    >> deal_output(output, id, prefix)
    
    a1 =
    
         4
    
    
    a2 =
    
         5
    
    
    a3 =
    
         6
    

    Also check out the join.m file on FileExchange for avoiding the ugly sprintf.

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

Sidebar

Related Questions

Currently I have a function which loops to create multiple HTML objects. Each time
I currently have a partial-application function which looks like this: Function.prototype.curry = function() {
How would I create a nested list, I currently have this public function getNav($cat,$subcat){
Currently I have a function which can take the start time and end time
I currently have a function that looks like this: public void AnimateLayoutTransform(object ControlToAnimate) {
I currently have a function [C#] which takes a byte[] and an alignment to
Currently I have an Atoi function in Java which returns an int value on
I currently have a variadic function which takes an arbitrary number of arguments of
I currently have this function which appends an input to the #cursor-start div: var
I've got a function which loads various models, and currently have this kind of

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.