Don't know whats wrong with my matlab script?
-
x = [ 1 2 3 4 5] y = [ 3 5 6 9 2] plotcolor = input('What type of color do you want (r(red) b(blue) or g(green)): ','s'); plottype = input('What type of plot style would you like(cirlce(o) or star(*)): ','s'); pstr = sprintf('%s%s',plotcolor,plottype') plot(x,y,'pstr') the problem is to create a script that will create x and y vectors. then the script will ask the user for a color and for a plot style. it will then create a string pstr that contains the color and plot style, so tat the call to the plot function be plot(x,y,pstr). For example, if the user enter 'blue' and star(*), the variable pstr would contain 'b*' I feel like i have done this exactly but i keep getting an error that reads ??? Undefined function or variable 's'. Error in ==> length at 2 area = sqrt(s*(s-a)*(s-b)*(s-c)); Error in ==> cla at 19 if nargin>0 && length(varargin{1})==1 && ishghandle(varargin{1}) && strcmpi((get(varargin{1},'Type')),'axe… Error in ==> newplot>ObserveAxesNextPlot at 125 cla(ax, 'reset',hsave); Error in ==> newplot at 74 ax = ObserveAxesNextPlot(ax, hsave); Error in ==> peterpan at 6 plot(x,y,'r*')
-
Answer:
I do not receive the same error as you. However the one thing I see wrong in your script is that you call: plot(x,y,'pstr') A working script for me is: x = [ 1 2 3 4 5]; y = [ 3 5 6 9 2]; plotcolor = input('What type of color do you want (r(red) b(blue) or g(green)): ','s'); plottype = input('What type of plot style would you like(cirlce(o) or star(*)): ','s'); pstr = sprintf('%s%s',plotcolor,plottype); plot(x,y,pstr); The plot function will try to evaluate 'pstr' as a string and not the variable if you use it in quotes. The values 'pstr' are not valid arguments in the color/linetype argument for plot. If you still are receiving errors, try to delete all the variables in your workspace and clean up your script file.
Joseph at Yahoo! Answers Visit the source
Related Q & A:
- Don't know a name of the song? What to do?Best solution by Yahoo! Answers
- Feeling sick, but I don't know what it's from?Best solution by Yahoo! Answers
- Is there any way I can get my MSN password back if I don't know the secret question that it asks?Best solution by Yahoo! Answers
- How do I find a certain tv channel if I don't know what number it is?Best solution by timewarnercable.com
- Don't know anything about football! What are the rules n stuff?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.