When I plot, I only get 5 red dots and a blank graph.

if true
}
clc
clear all
L = 5;
D = 3;
d = 1;
t = 0.1;
w = 500;
x = linspace(0, 1, L);
di = (x./L) * ( d - D) + D;
do = D + d - di;
VR = do / di;
plot(x , VR , 'b');
}
end
i'm new to Matlab, but the graphing procedure sounds really convoluted. I want for 'x' to be my horizontal axis and for VR to be my vertical axis. The graph should look something like a trapezoid if I did my math correct but I can't tell because it won't print the graph. I used '(x./L)' because I read that that makes it a vector, but it didn't change anything with or without it.

Answers (2)

You should make two changes:
x = linspace(0, 1, w); (or just linspace(0,1) and get the default hundred points)
VR = do ./ di; (You left out the dot)
Oh! that changes everything. Yes I see now why the "./" should be there instead of where I put it. I'll admit, I was guessing and focusing more on the "x" part of my equation rather than the equation itself. Thank you!

1 Comment

Jeremy, you should have put this as a comment to Roger, rather than as a new Answer to your original question. Also, please vote for his answer and "Accept" it so he gets reputation points for it.

Sign in to comment.

Categories

Find more on Graphics Performance in Help Center and File Exchange

Asked:

on 3 Apr 2016

Commented:

on 3 Apr 2016

Community Treasure Hunt

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

Start Hunting!