Plotting a Quarter Circle in MATLAB

  • Thread starter Thread starter jhnreid86
  • Start date Start date
  • Tags Tags
    Matlab Plot
Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
1 reply · 2K views
jhnreid86
Messages
1
Reaction score
0

Homework Statement



I am trying to plot simply a quarter of a circle but am having difficulty with it.




Homework Equations





The Attempt at a Solution



So far I have


x = 0:0.01:1;

for i = 0:length(x)

y = sqrt(1 - x(i)^2);

plot(x,y,'b-')

end


Basically what I am trying to do here is create a vector x with values from 0 to 1, and then plot each corresponding y coordinate.

I keep getting the following error

? Attempted to access x(0); index must be a positive integer or logical.

Error in ==> Untitled5 at 5
y = sqrt(1 - x(i)^2);


Any help would be greatly appreciated!
 
Physics news on Phys.org
you are trying to access the zeroeth index, MATLAB indices start with 1 and not 0.