0

I have a function in which I need to input a name which later assigns a name to the output the matfile.

function(filename2) % we need to input i.e "systolicAmplitude"
filename=[HBO;HBR];
matfileGroupInfo=strcat(filename2,'.mat');
save(matfileGroupInfo)

I faced an error "string cannot be used as a variable name". Any solution how I can solve the problem?

**I have the option to re-write the code as below:

 function(filename) % we need to input i.e "systolicAmplitude"
vec=[HBO;HBR];
matfileGroupInfo=strcat(filename2,'.mat');
save(matfileGroupInfo,'vec')

but it saves the variable under name of systolicAmplitude.vec. This is not favored for me.

2
  • Those snippets are sooooo confusing. What HBO and HBR are? How are you retrieving them? What is that function declaration? Commented Apr 25, 2018 at 22:35
  • Try using single quotes in 'systolicAmplitude'. Commented Apr 25, 2018 at 22:43

1 Answer 1

2

I guess something else is wrong. I fixed the function format in your code and it works fine and saves the the *.mat file in the current directory.

function Blah(filename2) % we need to input i.e "systolicAmplitude"
vec=['HBO';'HBR'];
matfileGroupInfo=strcat(filename2,'.mat');
save(matfileGroupInfo,'vec')

When you call the function like Blah('systolicAmplitude'), it writes the 'vec' into the mat file and the saves systolicAmplitude.mat in the current directory.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.