![untitled.png](https://www.mathworks.com/matlabcentral/answers/uploaded_files/213655/untitled.png)
Making a array that gives me this kind of data...?
2 次查看(过去 30 天)
显示 更早的评论
I want to write a code with given xp, x1 and depth values that can give me value of y axis with given x.
![Drawing (1).jpeg](https://www.mathworks.com/matlabcentral/answers/uploaded_files/213641/Drawing%20(1).jpeg)
I want a code to which if I give x, it provides me with value of y and y should be as given in above photo.
My attept:
clear; clc;
xp = 100;
x1 = 50;
dx = 0.2;
depth = 1;
all_x = -xp:dx:xp;
y1 = linspace(0,0,length( [-xp:dx:-x1] ) )
y2 = ???
y3 = linspace(0,0,length( [x1:dx:xp] ) )
all_y = [y1 y2 y3];
I am unable to write a relation for y2
0 个评论
采纳的回答
Stephen23
2019-4-13
>> xp=5;
>> x1=1.5;
>> depth=2.3;
>> Xv = -xp:0.1:xp;
>> Yv = min(0,depth*abs(Xv)/x1 - depth);
>> plot(Xv,Yv,'-*')
![untitled.png](https://www.mathworks.com/matlabcentral/answers/uploaded_files/213655/untitled.png)
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!