Why does this split of the plot lines doesn't work?

7 ビュー (過去 30 日間)
Fabian Rüeger
Fabian Rüeger 2017 年 1 月 6 日
編集済み: John BG 2017 年 1 月 10 日
x = linspace(0,8.7,1000)
a = zeros (1,1000)
b = zeros (1,1000)
c = zeros (1,1000)
d = zeros (1,1000)
hold on;
grid on;
%////////////////////////////////////////////////Fall 1///////////////////
figure(1);
for i = 1:1000
a(i) = 6.5*4000./((6.5-x(i)));
b(i) = 10500
c(i) = 6.5*9500./((x(i)));
d(i) = 500./(x(i)-6.5);
if a(i)<b(i)
plot(x,a,'.')
end
if d(i)<c(i)<b(i)
plot(x,c,'.')
end
if d(i)<c(i)
plot(x,d,'.')
end
plot(x,b,'.')
end
axis([0 10 0 12000])

採用された回答

John BG
John BG 2017 年 1 月 9 日
編集済み: John BG 2017 年 1 月 10 日
the graph function is not the same as in grafik.png and the lower area needs some improvement, but would you consider the following a start point?
x=[1:1:100];y1=x([1:1:30]);y2=x(3)*ones(1,20);y3=x([30:-1:1]);y4=zeros(1,20);
y=[y1 y2 y3 y4];y=y+10;plot(x,y,'r')
patch('XData',x,'YData',y,'FaceColor','red','LineStyle','none')
axis([0 numel(x) 0 max(y)+5])
z=y-3; % lift
delay=7
z([1:1:end-delay+1])=z([delay:1:end]) % advance
hold all
plot(x,z,'b')

その他の回答 (3 件)

Walter Roberson
Walter Roberson 2017 年 1 月 6 日
if d(i)<c(i)<b(i)
means the same as
if ((d(i)<c(i))<b(i))
The calculation d(i)<c(i) returns back 0 (false) or 1 (true), and you then compare that 0 or 1 to b(i)
  1 件のコメント
Walter Roberson
Walter Roberson 2017 年 1 月 7 日
Fixing the if and adding some semi-colons produces a reasonable looking graph.

サインインしてコメントする。


John BG
John BG 2017 年 1 月 7 日
編集済み: John BG 2017 年 1 月 7 日
Herr Rüger
I am confident I can supply the correct answer, but i kindly ask for some clarification.
Dein script, with lines instead of dots, i have nur reduced the amount of points from 1000 down to 10:
x = linspace(0,8.7,10)
a = zeros (1,10)
b = zeros (1,10)
c = zeros (1,10)
d = zeros (1,10)
for i = 1:10
a(i) = 6.5*40./((6.5-x(i)));
b(i) = 105
c(i) = 6.5*95./((x(i)));
d(i) = 5./(x(i)-6.5);
if a(i)<b(i)
subplot(2,2,1);plot(x,a');axis([0 10 0 120]);grid on;hold all
end
if d(i)<c(i)<b(i)
figure(2);subplot(2,2,2);plot(x,c');axis([0 10 0 120]);grid on;hold all
end
if d(i)<c(i)
subplot(2,2,3);plot(x,d');axis([0 10 0 120]);grid on;hold all
end
subplot(2,2,4);plot(x,b');axis([0 10 0 120]);grid on;hold all
end
.
Aso, would you please define 'split' in the context of deine frage?
thanks for time and attention, awaiting comment
John BG

Fabian Rüeger
Fabian Rüeger 2017 年 1 月 7 日
編集済み: Fabian Rüeger 2017 年 1 月 7 日
Thank you for your answers. The final plot should look like this:->grafik.png
The diagramm describes a weight distribution of a lorry.
  1 件のコメント
John BG
John BG 2017 年 1 月 7 日
編集済み: John BG 2017 年 1 月 7 日
ok, so your question is not about splitting a plot, but how to add a shadow, to reproduce grafik.m in MATLAB, oder?

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeCreating, Deleting, and Querying Graphics Objects についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by