From: us on
"William " <william.baxter(a)oit.edu> wrote in message <i2n9v4$5dh$1(a)fred.mathworks.com>...
> "us " <us(a)neurol.unizh.ch> wrote in message <i2n8re$je3$1(a)fred.mathworks.com>...
> > "William "
> > > I think i get the idea behind it, but why isnt this working
> > >
> > > %%
> > > h= t*V*cos(angle); %height
> > > f= p+t*V*sin(angle) - 1/2*G*t.^2; %flight
> > > plot(h,f,'-');
> > > set(gca,'xlim',[0,length(h)],'ylim',[0,length(h)]) %Graphical restrictions
> > >
> > >
> > > % seems like this would allow the x and y axis to change restrictions based on the outcome of its respected x and y equation.
> >
> > hmm...
> > - why do you use LENGTH(H)...
> > - most CSSMers would probably use MAX(H)...
> >
> > just a thought...
> > us
>
>
> %%
> h= t*V*cos(angle); %height
> f= p+t*V*sin(angle) - 1/2*G*t.^2; %flight
> plot(h,f,'-');
> set(gca,'xlim',[0,(max(h)/2)],'ylim',[0,(max(f)+5)])%Graphical restrictions
>
>
> With this code I think its odd I need to divide max(h) by 2, and this still doesnt correctly resize my graph with some angles and velocity. The Y max works fine the x-axis is more difficult...I thought perhaps use length for the x values and max for the y, but that did not work either.

rather - strange...
can you give an example of your input, which shows the conundrum(?)...

us
From: Andy on
I'm not sure what the problem is, except that by setting the bottom of the ylim to 0, you're ignoring where f is negative. Perhaps you meant to trim this tail for both h and f?
From: William on
angle = input('Enter angle of trajectory= '); %Angle
V= input('Enter velocity= '); %Velocity
p= input('Enter Position of elevation= '); %Position
G= 9.8; %Gravity
t=0:0.1:20; %# of Calculations

%%
h= t*V*cos(angle); %height
f= p+t*V*sin(angle) - 1/2*G*t.^2; %flight
plot(h,f,'-');
set(gca,'xlim',[0,length(h)/2],'ylim',[0,(max(f)+5)]) %Graphical restrictions

% note the +5 in max(f)+5 is only to grow the graph slightly, for later annotation
% space.

Just about any input you can imagine doesnt allow the x format to work correctly, but here are some.

angle = 45
velocity = 55
position = 10

or

angle = 45
velocity = 155
position = 10
From: Alan B on
"William " <william.baxter(a)oit.edu> wrote in message <i2nblf$rj8$1(a)fred.mathworks.com>...
> angle = input('Enter angle of trajectory= '); %Angle
> V= input('Enter velocity= '); %Velocity
> p= input('Enter Position of elevation= '); %Position
> G= 9.8; %Gravity
> t=0:0.1:20; %# of Calculations
>
> %%
> h= t*V*cos(angle); %height
> f= p+t*V*sin(angle) - 1/2*G*t.^2; %flight
> plot(h,f,'-');
> set(gca,'xlim',[0,length(h)/2],'ylim',[0,(max(f)+5)]) %Graphical restrictions
>
> % note the +5 in max(f)+5 is only to grow the graph slightly, for later annotation
> % space.
>
> Just about any input you can imagine doesnt allow the x format to work correctly, but here are some...

Maybe you should use max(h) WITHOUT dividing by 2?

I don't know why you can't just use this very straightforward solution:
set(gca,'xlim',[min(h), max(h)],'ylim',[min(f), max(f)]) %Graphical restrictions
From: us on
"William " <william.baxter(a)oit.edu> wrote in message <i2nblf$rj8$1(a)fred.mathworks.com>...
> angle = input('Enter angle of trajectory= '); %Angle
> V= input('Enter velocity= '); %Velocity
> p= input('Enter Position of elevation= '); %Position
> G= 9.8; %Gravity
> t=0:0.1:20; %# of Calculations
>
> %%
> h= t*V*cos(angle); %height
> f= p+t*V*sin(angle) - 1/2*G*t.^2; %flight
> plot(h,f,'-');
> set(gca,'xlim',[0,length(h)/2],'ylim',[0,(max(f)+5)]) %Graphical restrictions
>
> % note the +5 in max(f)+5 is only to grow the graph slightly, for later annotation
> % space.
>
> Just about any input you can imagine doesnt allow the x format to work correctly, but here are some.
>
> angle = 45
> velocity = 55
> position = 10

well...
you're still using LENGTH()...
why(?)...

set(gca,'xlim',[0,length(h)/2],'ylim',[0,(max(f)+5)]) %Graphical restrictions

using your input, then

yrng=.1*(max(f)-min(f)); % <- +/- 10% for the eye...
set(gca,'xlim',[0,max(h)],'ylim',[min(f)-yrng,max(f)+yrng]);
% displays reasonably well...

us