Making a point of data into matrix/vector form

2 views (last 30 days)
my while loop for my every variable, n run ill get my i and therefore i got a few x and y coordinate in which when i use plot (x,y) they appear in dots only not in line how i make my graph into both dots and line?

Accepted Answer

Star Strider
Star Strider on 9 May 2015
You did not post any code, but this is not the first time this problem has presented here.
Subscript your ‘x’ and ‘y’ values in the loop, then plot them after the loop.
For example:
for k1 = 1:10
x(k1) = k1.^2;
y(k1) = 3 + 2*k1;
end
figure(1)
plot(x, y)
grid
Also, it is best not to use ‘i’ or ‘j’ as variables or loop counters in your code. MATLAB uses them for its imaginary operators, and using them as variables can be confusing.
  12 Comments
Victor Seaw
Victor Seaw on 9 May 2015
thanks and i used matrix addressing where N(1:end-1) in the plot which is more effective and less redundant because marks will be given on the most fastest way
Star Strider
Star Strider on 9 May 2015
My pleasure.
If my Answer solved your problem, please Accept it.

Sign in to comment.

More Answers (0)

Categories

Find more on 2-D and 3-D Plots in Help Center and File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!