[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: plot octave graph by running .m file problem
From: |
Allen.Windhorn |
Subject: |
RE: plot octave graph by running .m file problem |
Date: |
Wed, 14 Oct 2015 15:57:40 +0000 |
Manpreet,
> -----Original Message-----
> From: Manpreet Dhiman [mailto:address@hidden
>
> function k=value(doverA,aoverA)
> up=(1-(aoverA)^2-(2*aoverA*doverA)-(doverA)^2);
> down=(aoverA*doverA+(doverA)^2);
> k=up/down;
> end
>
> for aoverA=0:5:100
> for doverA = 0:0.05:0.30
> k=value(doverA,aoverA) %calling of function
> plot([0; aoverA(:,1)], [0;doverA],'-ro')
> hold on
The plot function requires two arrays as input.
The two arrays you are giving it are [0; aoverA], which is the x axis,
and [0, aoverA], which is the y axis. So it plots the points (0,0) and
((aoverA,aoverA) and plots a line between them.
You need to tell it to plot aoverD as a function of k. This would be
plot(k, aoverD)
But k and aoverD can't just be numbers, they have to be arrays with
ALL the values of k and aoverD in them, with a separate plot for each
value of aoverA, with hold on so they are all plotted on the same graph.
Type "help plot" to find out how plot works.
> endfor
Big hint: your plot command needs to be here, not in the inner loop.
But you need to figure out how to make arrays for k and aoverD.
Best way would be to make your function accept an array and produce
an array. Google "octave element by element". Then you can get rid
of the inner loop. Or look up "array append".
Try doing it by hand once and take note of the steps you have to go
through to get the graph.
> endfor
Regards,
Allen
- Re: plot octave graph by running .m file problem, (continued)
- Re: plot octave graph by running .m file problem, Carlo de Falco, 2015/10/15
- Re: plot octave graph by running .m file problem, Manpreet Dhiman, 2015/10/15
- Re: plot octave graph by running .m file problem, Doug Stewart, 2015/10/13
- RE: plot octave graph by running .m file problem, Allen.Windhorn, 2015/10/13
- RE: plot octave graph by running .m file problem, Manpreet Dhiman, 2015/10/14
- Re: plot octave graph by running .m file problem, Doug Stewart, 2015/10/14
- Re: plot octave graph by running .m file problem, Manpreet Dhiman, 2015/10/14
- Re: plot octave graph by running .m file problem, Doug Stewart, 2015/10/14
- Re: plot octave graph by running .m file problem, Manpreet Dhiman, 2015/10/14
- Message not available
- RE: plot octave graph by running .m file problem,
Allen.Windhorn <=