I'm wanting to call a function exactly like this but in a different way:(adsbygoogle = window.adsbygoogle || []).push({});

[Out1,Out2] = BeginName_MiddleName_EndName(In1,In2);

Basically what I want to do is call this function as simply and elegantly as possible while defining "MiddleName" separately -- this is because I use the same term "MiddleName" for different functions (e.g. function names: solver_001_compute, figures_001_display, etc... where "MiddleName" is "001").In other words, I am looking to set the middle name, then use it in a function as part of the name of the function (a part of the string). Keep in mind that I have inputs.

I have one that works (see below), but there should be an easier way to do it -- in two lines (1 to define Case, then the other to operate the function -- eliminating the second line of code below). The problem I face is having inputs in a concatenated str2func string. What is the simplest code for "str2func" with inputs and a pieced together function name such as the one below?

Case = 'MiddleName';

funcName = str2func(['BeginName_' Case '_EndName']);

[Out1,Out2] = funcName(In1,In2);

**Physics Forums - The Fusion of Science and Community**

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# MATLAB str2func help

Can you offer guidance or do you also need help?

Draft saved
Draft deleted

Loading...

Similar Threads - MATLAB str2func help | Date |
---|---|

Matlab Coding angular spectrum of waves in a fluid | Thursday at 7:30 AM |

How to program this in Matlab | Feb 28, 2018 |

Matlab Making a short test for self-adjointness | Feb 23, 2018 |

Matlab MATLab: Not enough inputs for nlinfit | Nov 16, 2017 |

**Physics Forums - The Fusion of Science and Community**