MATLAB Answers

Plotting y = kx

15 views (last 30 days)
Behnaz Seyedahmadi
Behnaz Seyedahmadi on 4 Oct 2020
I am trying to reproduce the following graph, which is a plot of some function like: y = kx, with both varying 'k' and 'x'. Can someone help me in this?
Behnaz Seyedahmadi
Behnaz Seyedahmadi on 5 Oct 2020
it is simpler than taht, I dont know why I am stuck in it, it is this way:
y = k.* x
but I dont know how to match the x and K size?

Sign in to comment.

Answers (2)

Walter Roberson
Walter Roberson on 5 Oct 2020
N = 150;
kvec = linspace(0, 1000, N);
xvec = linspace(0, 20225, N);
[k, y] = meshgrid(kvec, xvec);
y = k .* x;
nlevels = 50;
contour(k, y, nlevels)

Sulaymon Eshkabilov
Sulaymon Eshkabilov on 5 Oct 2020
x =1:2024;
F = k.* x(:);
N = 25;
contour(k, x, F, N), shg
xlabel('k stifness'), ylael(' ...')


Community Treasure Hunt

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

Start Hunting!