Hi,(adsbygoogle = window.adsbygoogle || []).push({});

I am writing a Matlab function(script), which take some input.

I have several datasets in the workspace, say dataset1,dataset2,dataset3, ect

In my function, I have tried to use

data = input('Please input your dataset', 's')

and then use 'data' as a variable for some computation, say

sum(data);

mean(data);

It does not work. I wonder what's the 'correct' way to do it?

=====================================================

OR, I can add an argument in myfunction, say

function y = myf(ds,para)

use 'ds' to indicate the dataset that i want to use.

However, in this case, how should i use 'fminsearch' for optimization?

'fminsearch' will then treat this 'ds' input as a parameter.

=====================================================

Thanks!

**Physics Forums | Science Articles, Homework Help, Discussion**

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

# Matlab input string as variable name (or other ways)

Can you offer guidance or do you also need help?

Draft saved
Draft deleted

Loading...

Similar Threads for Matlab input string |
---|

MATLAB MATLAB: forces acting on an object |

MATLAB Matlab histogram |

MATLAB Sovling Bernoulli's differential equation in matlab? |

MATLAB Matlab-like software |

MATLAB MATLab: Not enough inputs for nlinfit |

**Physics Forums | Science Articles, Homework Help, Discussion**