I will plot both function in the same diagramm? What is wrong?
clear all, close all, clc
v=1000*0.005*0.995; %Varianz
sigma = sqrt(v); %Standardabweichung
mu = 1000*0.005; %Erwartungswert
dt = 0.1; %Schrittweite
t = 0:dt:10;
Phi(1)= 0; %Startwert
for n=1:length(t),
%Dichtefunktion
phi(n)=1/(sqrt(2+pi)*sigma)*exp(-(t(n)-mu)^2/(2*sigma^2));
%Rechteckintegration
Phi(n+1) = Phi(n) + phi(n)*dt;
end
%Darstellung
p=1-Phi(end),
figure(1),
plot(t,phi),grid on,
title('Glockenkurve der gaußschen Normalverteilung'),
xlabel('Samenkörner');
ylabel('Dichtefunktion');

 採用された回答

Walter Roberson
Walter Roberson 2016 年 10 月 13 日

1 投票

plot(t, phi, t, Phi)
In general you can also use
plot(t, phi)
hold on
plot(t, Phi)
hold off

2 件のコメント

Daniel Münch
Daniel Münch 2016 年 10 月 13 日
Now I receive error message
|Error using plot Vectors must be the same lengths.
Error in aufgabe1cc (line 23) plot (t,Phi),|
Walter Roberson
Walter Roberson 2016 年 10 月 13 日
True. Your loop creates Phi(n+1) for each of the length(t) timesteps, so you have one extra Phi. How do you want to handle that?
My guess is you want
plot(t, phi, t, Phi(2:end))

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeLine Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by