<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/156313</link>
    <title>MATLAB Central Newsreader - input problems: beginner in matlab</title>
    <description>Feed for thread: input problems: beginner in matlab</description>
    <language>en-us</language>
    <copyright>&amp;copy;1994-2012 by MathWorks, Inc.</copyright>
    <webmaster>webmaster@mathworks.com</webmaster>
    <generator>MATLAB Central Newsreader</generator>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <ttl>60</ttl>
    <image>
      <title>MathWorks</title>
      <url>http://www.mathworks.com/images/membrane_icon.gif</url>
    </image>
    <item>
      <pubDate>Mon, 17 Sep 2007 20:50:05 -0400</pubDate>
      <title>input problems: beginner in matlab</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/156313#392766</link>
      <author>Eddy </author>
      <description>x=[1:1:10]&lt;br&gt;
fprintf('please enter a function like sin cos exp etc,\n')&lt;br&gt;
fprintf('the calculation performed will be like&lt;br&gt;
pfun(funct(x)),\n')&lt;br&gt;
fprintf('where funct is your function and x= 0 to 10&lt;br&gt;
increment with 1,\n')&lt;br&gt;
funct=input('function funct=','s')&lt;br&gt;
pfun=funct'(x)'&lt;br&gt;
&lt;br&gt;
In the technical course we are starting to learn Matlab for&lt;br&gt;
signal processing.&lt;br&gt;
So now we have to do all kinds of exercises, and I do like it.&lt;br&gt;
But one thing does not fall in to place.&lt;br&gt;
In the above script I prompt for a input from the user and&lt;br&gt;
store this in a variable 'funct' the input is as a string.&lt;br&gt;
now I want to use what is in the string to doe some&lt;br&gt;
computing but this last step will not succeed.&lt;br&gt;
So if the input would be sin the computation should be sin(x)&lt;br&gt;
&lt;br&gt;
Can somebody help me with this probably syntax problem??&lt;br&gt;
&lt;br&gt;
thanks&lt;br&gt;
&lt;br&gt;
Eddy</description>
    </item>
    <item>
      <pubDate>Mon, 17 Sep 2007 21:04:38 -0400</pubDate>
      <title>Re: input problems: beginner in matlab</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/156313#392770</link>
      <author>Travis </author>
      <description>Is this what you mean?&lt;br&gt;
&lt;br&gt;
x=[1:1:10];&lt;br&gt;
funct = input('function to evaluate = ','s');&lt;br&gt;
to_evaluate = [funct '(x)'];&lt;br&gt;
y = eval(to_evaluate)&lt;br&gt;
&lt;br&gt;
(should work if you input the correct built in matlab&lt;br&gt;
function names... ie sin, cos, tan, etc...)&lt;br&gt;
&lt;br&gt;
Might be a better way to do it, but I think that might work.&lt;br&gt;
&lt;br&gt;
--Travis&lt;br&gt;
&lt;br&gt;
&quot;Eddy &quot; &amp;lt;grotehaas@mathworks.com&amp;gt; wrote in message&lt;br&gt;
&amp;lt;fcmp9t$3vj$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; x=[1:1:10]&lt;br&gt;
&amp;gt; fprintf('please enter a function like sin cos exp etc,\n')&lt;br&gt;
&amp;gt; fprintf('the calculation performed will be like&lt;br&gt;
&amp;gt; pfun(funct(x)),\n')&lt;br&gt;
&amp;gt; fprintf('where funct is your function and x= 0 to 10&lt;br&gt;
&amp;gt; increment with 1,\n')&lt;br&gt;
&amp;gt; funct=input('function funct=','s')&lt;br&gt;
&amp;gt; pfun=funct'(x)'&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; In the technical course we are starting to learn Matlab for&lt;br&gt;
&amp;gt; signal processing.&lt;br&gt;
&amp;gt; So now we have to do all kinds of exercises, and I do like it.&lt;br&gt;
&amp;gt; But one thing does not fall in to place.&lt;br&gt;
&amp;gt; In the above script I prompt for a input from the user and&lt;br&gt;
&amp;gt; store this in a variable 'funct' the input is as a string.&lt;br&gt;
&amp;gt; now I want to use what is in the string to doe some&lt;br&gt;
&amp;gt; computing but this last step will not succeed.&lt;br&gt;
&amp;gt; So if the input would be sin the computation should be sin(x)&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Can somebody help me with this probably syntax problem??&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; thanks&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Eddy</description>
    </item>
    <item>
      <pubDate>Mon, 17 Sep 2007 21:30:06 -0400</pubDate>
      <title>Re: input problems: beginner in matlab</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/156313#392774</link>
      <author>Eddy </author>
      <description>yes that's what I mean,&lt;br&gt;
thanks for your help Travis,&lt;br&gt;
&lt;br&gt;
Eddy&lt;br&gt;
&lt;br&gt;
&quot;Travis &quot; &amp;lt;traviib.nospam.@yahoo.com&amp;gt; wrote in message&lt;br&gt;
&amp;lt;fcmq56$i9h$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; Is this what you mean?&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; x=[1:1:10];&lt;br&gt;
&amp;gt; funct = input('function to evaluate = ','s');&lt;br&gt;
&amp;gt; to_evaluate = [funct '(x)'];&lt;br&gt;
&amp;gt; y = eval(to_evaluate)&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; (should work if you input the correct built in matlab&lt;br&gt;
&amp;gt; function names... ie sin, cos, tan, etc...)&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Might be a better way to do it, but I think that might work.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; --Travis&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &quot;Eddy &quot; &amp;lt;grotehaas@mathworks.com&amp;gt; wrote in message&lt;br&gt;
&amp;gt; &amp;lt;fcmp9t$3vj$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt; x=[1:1:10]&lt;br&gt;
&amp;gt; &amp;gt; fprintf('please enter a function like sin cos exp etc,\n')&lt;br&gt;
&amp;gt; &amp;gt; fprintf('the calculation performed will be like&lt;br&gt;
&amp;gt; &amp;gt; pfun(funct(x)),\n')&lt;br&gt;
&amp;gt; &amp;gt; fprintf('where funct is your function and x= 0 to 10&lt;br&gt;
&amp;gt; &amp;gt; increment with 1,\n')&lt;br&gt;
&amp;gt; &amp;gt; funct=input('function funct=','s')&lt;br&gt;
&amp;gt; &amp;gt; pfun=funct'(x)'&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; In the technical course we are starting to learn Matlab for&lt;br&gt;
&amp;gt; &amp;gt; signal processing.&lt;br&gt;
&amp;gt; &amp;gt; So now we have to do all kinds of exercises, and I do&lt;br&gt;
like it.&lt;br&gt;
&amp;gt; &amp;gt; But one thing does not fall in to place.&lt;br&gt;
&amp;gt; &amp;gt; In the above script I prompt for a input from the user and&lt;br&gt;
&amp;gt; &amp;gt; store this in a variable 'funct' the input is as a string.&lt;br&gt;
&amp;gt; &amp;gt; now I want to use what is in the string to doe some&lt;br&gt;
&amp;gt; &amp;gt; computing but this last step will not succeed.&lt;br&gt;
&amp;gt; &amp;gt; So if the input would be sin the computation should be&lt;br&gt;
sin(x)&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; Can somebody help me with this probably syntax problem??&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; thanks&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; Eddy&lt;br&gt;
&amp;gt; </description>
    </item>
    <item>
      <pubDate>Tue, 18 Sep 2007 03:02:33 -0400</pubDate>
      <title>Re: input problems: beginner in matlab</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/156313#392807</link>
      <author>Nick Denman</author>
      <description>Hi Eddy&lt;br&gt;
&lt;br&gt;
&quot;Eddy &quot; &amp;lt;grotehaas@mathworks.com&amp;gt; wrote in message &lt;br&gt;
&amp;lt;fcmp9t$3vj$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; x=[1:1:10]&lt;br&gt;
&amp;gt; fprintf('please enter a function like sin cos exp &lt;br&gt;
etc,\n')&lt;br&gt;
&amp;gt; fprintf('the calculation performed will be like&lt;br&gt;
&amp;gt; pfun(funct(x)),\n')&lt;br&gt;
&amp;gt; fprintf('where funct is your function and x= 0 to 10&lt;br&gt;
&amp;gt; increment with 1,\n')&lt;br&gt;
&amp;gt; funct=input('function funct=','s')&lt;br&gt;
&amp;gt; pfun=funct'(x)'&lt;br&gt;
&lt;br&gt;
help str2func&lt;br&gt;
&lt;br&gt;
E.g.&lt;br&gt;
x = 1:10;&lt;br&gt;
str = 'sin';&lt;br&gt;
fcn = str2func(str);&lt;br&gt;
fcn(x)&lt;br&gt;
&lt;br&gt;
--&lt;br&gt;
Nick</description>
    </item>
  </channel>
</rss>

