In my command window only the file name appears
Show older comments
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 Comments
Walter Roberson
on 12 Mar 2018
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
on 13 Mar 2018
Answers (1)
Rakshith Naraganhalli
on 21 Feb 2021
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 Comments
Walter Roberson
on 21 Feb 2021
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
on 21 Feb 2021
Edited: Walter Roberson
on 6 Mar 2022
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.
Categories
Find more on Annotations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!