In my command window only the file name appears

42 ビュー (過去 30 日間)
Sarah Meier
Sarah Meier 2018 年 3 月 12 日
編集済み: Walter Roberson 2022 年 3 月 6 日
If I want to run a code in the command window only the file name 'homework' appears. I'm trying to create a matrix with the code A=randn(3,3); If i write something trivial like
a=2
b=3*a
it works. But not for much more.
I'd be very grateful for a solution.
  2 件のコメント
Walter Roberson
Walter Roberson 2018 年 3 月 12 日
The line of code
A=randn(3,3);
assigns random numbers to A. Then the semi-colon at the end of the line tells it to not display any result on the screen. Nothing would be output to the display. This is normal operation.
Sarah Meier
Sarah Meier 2018 年 3 月 13 日
Thank you so much!

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

回答 (1 件)

Rakshith Naraganhalli
Rakshith Naraganhalli 2021 年 2 月 21 日
mu_min=2.4; mu_max=4; %range of mu values
n_trans=200000; %transient iterations
n_data=100000; %number of x values per mu value
x_0=0.5; %initial condition
x_data=zeros(1,500);
x_a=zeros(1,100000);
mu=linspace(mu_min,mu_max,500);
for k=1:1:500
m=mu(k);
x_0=0.5;
for i=1:1:n_trans
x_i=x_0*m*(1-(x_0));
x_0=x_i;
end
for j=1:1:500
x_a(j)=x_0*m*(1-(x_0));
x_0=x_a(j);
end
x_data(k)=x_0;
end
plot(x_data,mu)
%CAN ANYONE PLEASE TELL WHY THE FILE NAME IS APPEARING IN THE COMMAND WINDOW. IF THERE IS ANYTHING WROG IN THE CODE CAN YOU PLEASE SUGGEST CHANGES
  2 件のコメント
Walter Roberson
Walter Roberson 2021 年 2 月 21 日
If you are in the editor and you press the green Run button to execute the code, then the way that matlab implements Run is that it injects the file name into the command window and automatically presses Return, so the code is started exactly the same way as if you had typed the file name in the command window yourself. It is the normal way that code is executed.
Walter Roberson
Walter Roberson 2021 年 2 月 21 日
編集済み: Walter Roberson 2022 年 3 月 6 日
plot(x_data,mu)
The convention for plotting is that the independent variable should appear in the horizontal axes and the dependent variable should appear in the vertical axes. mu is the independent variable, so normally it would be the horizontal axes, but you made it the vertical axes in your plot call. I would recommend that you add a comment into your code describing why you did that, as otherwise people are likely to think that you made a mistake in the code.

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

カテゴリ

Help Center および File ExchangeGraphics Objects についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by