Running same program is giving different plot

4 ビュー (過去 30 日間)
Heya :)
Heya :) 2020 年 10 月 17 日
編集済み: Heya :) 2020 年 10 月 18 日
Everytime I run a program I get different plot for error. Why is that? How to resolve this issue? Please help
clear all; close all; clc;
%value of constants
a=0.1;
omega=5;
dt=0.01; %step size
x(1)=1;
y(1)=1;
for i=2:1000
x(i)=x(i-1)+((a-x(i-1)^2-y(i-1)^2)*x(i-1)-omega*y(i-1))*dt;
y(i)=y(i-1)+((a-x(i-1)^2-y(i-1)^2)*y(i-1)+omega*x(i-1))*dt;
end
index=randi([2,999],1,N_m);
  1 件のコメント
Rafael Hernandez-Walls
Rafael Hernandez-Walls 2020 年 10 月 17 日
maybe it's because you're using this command: index=randi([2,999],1,N_m);

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

採用された回答

Rik
Rik 2020 年 10 月 17 日
Clear all should only exist exactly once in your entire code base. Replace it with clear or clearvars.
If you want to have repeatable code with randomness you will have to set the random seed. You can use the rng function to do so.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGet Started with MATLAB についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by