user function and plot
Show older comments
function [x1,x2]=distance_plot(W)
prompt1=('input value of W(N) = ') %W값 입력받기
prompt2=('input value of d(m) = ') %d값 입력받기
W=input(prompt1);
d=input(prompt2);
k1=104; %단위:N/m
k2=1.5*10^4; %단위:N/m
W0=linspace(0,W,1000);
x=0;
if x<d
x1=W/k1;
else x>=d
x2=(W+2*k2*d)/(k1+2*k2);
end
if x<d
x=linspace(0,d,1000);
plot(x1,W0)
xlabel('x1')
ylabel('W')
grid
else x>=d
x=linspace(0,d,1000);
plot(x2,W0)
xlabel('x2')
ylabel('W')
grid
end
(Don't care about the comments)
hello
i made a code(used defined function).
i thought about drawing a graph with a specified range according to the value of 'W' and 'd'.
there is no error code but graph didn't appear in the figure window.
Is it wrong to put the input value 'W' and 'd' directly into the ( W0=linspace(0,W,1000); ) and ( x=linspace(0,d,1000); )?
any other wrong?
thanks!
1 Comment
Rik
on 17 Nov 2022
You're already writing a function, so why not have W and d both as input arguments? You're currently overwriting your input argument W in that input statement.
Accepted Answer
More Answers (0)
Categories
Find more on 2-D and 3-D Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!