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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T13:27:29+00:00 2026-06-08T13:27:29+00:00

Hi there I’m currently trying to find a way to save 2 variables from

  • 0

Hi there I’m currently trying to find a way to save 2 variables from my workspace into a file. I want the file name to be put together using the original and the current date.

I only want the max value from the variables so:

max(streaking)

and

max(tap_total)

The original file name is:

3_FM001_02_05460$BandP$64_24000_FWD_1x1_PRI_PRI_PRI_PRI_15_17_ActivePixelMeans.csv

The only portion of this original file name that I would like to use is:

3_FM001_02_05460$BandP$64_24000_FWD_1x1

These can be saved in a text file or spreadsheet, it doesnt matter.

An example of the new file name would be something like this:

3_FM001_02_05460$BandP$64_24000_FWD_1x1_7-26-2012

Also,

If something could be done in the file to display which variable is which, for example:

Streaking: 1.272  % this would come from the variable max(streaking)

Tap_Total: 2.252  % this would come from the varaible max(tap_total)

EDIT:

% Construct a questdlg with three options

choice = questdlg('Would you like to save?', ...

'Save Options', ...

'Yes','No','Cancel','Cancel');

% Handle response

switch choice

case 'Yes'

    disp([choice ' processing.'])

    save_option = 1;
case 'No'
    disp([choice ' processing.'])
    save_option = 0;
case 'Cancel'
    disp('Canceled.')
    save_option = 2;
end

file_to_get = evalin( 'base', 'file_to_get' );
streaking = evalin( 'base', 'streaking' );
tap_total = evalin( 'base', 'tap_total' );

if save_option == 0
elseif save_option == 1

    max_streak = max(streaking);
    max_tap = max(tap_total);
    str_streak = mat2str(max_streak);
    str_tap = mat2str(max_tap);
    fname = file_to_get;
    pruned_fname = regexprep(fname,'_PRI(\w*).(\w*)','');
    new_fname = [pruned_fname '_' date '.csv'];
    path1 = '\\pfile01thn\bbruffey$\My Documents\analysis data\Banding and Streaking Results';
    fid = fopen([path1 new_fname], 'w');
    fprintf(fid,['Max Banding: %s\nMax Streaking: %s'],str_tap,str_streak)
    fclose(fid);
elseif save_option == 2
end
  • 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-06-08T13:27:31+00:00Added an answer on June 8, 2026 at 1:27 pm

    This would be a great place to use the regexprep command to prune the original filename down.

    Example:

    fname = '3_FM001_02_05460$BandP$64_24000_FWD_1x1_PRI_PRI_PRI_PRI_15_17_ActivePixelMeans.csv';
    pruned_fname = regexprep(fname,'_PRI(\w*).(\w*)','');
    
    pruned_fname =
    
    3_FM001_02_05460$BandP$64_24000_FWD_1x1
    

    Now, a note about the regexprep command I used here. This is specific for the filename you provided here. Since it looks like you want to trim off everything after the the first _PRI I used a tag (\w*) which means any combination of [a-z A-Z _ 0-9] can follow. Notice that since this is a filename there is a . there hence why I added a period in and followed that with another (\w*) to finish out the csv. You can find more info on these sorts of operators here.

    Now that you have the pruned_fname you can simply add whatever you want to it. So if you want to add the date in with an underscore to space it just simply do something like this:

    new_fname = [pruned_fname '_' date '.csv'];
    new_fname =
    
    3_FM001_02_05460$BandP$64_24000_FWD_1x1csv_26-Jul-2012.csv
    

    Now you simply need to open the file to write to it. you might need to append the path to where you want to save it, I’m just going to call it path for now. It would be something like C:\Documents\

    fid = fopen([path new_fname], 'w')
    

    Now with the fid you have the id of the file you want to write to. This should be a new file and if it isn’t you are going to overwrite the file contents if you do it this way. Just be aware =)

    Next you can simply write those first two lines to the file using fwrite fprintf, just to name a few possible functions.

    Hopefully that’ll get you setup there!

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

Sidebar

Related Questions

I want use html5's new tag to play a wav file (currently only supported
I am currently running into a problem where an element is coming back from
There is a directed graph having a single designated node called root from which
There are two intents on the receiver side which are called from the same
There is any way to set the generic type (T) of class in the
I have just tried to save a simple *.rtf file with some websites and
There are many string matching algorithms can be used to find a pattern (string)
There are a lot of Jquery plugins and libraries. and sometimes I want to
There is a text file with 1,000,000 lines of code floating around and Ctrl+F
I am trying to render a haml file in a javascript response like so:

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.