Ask about matlab code line by line

2 vues (au cours des 30 derniers jours)
Thanapong likhitparinya
Thanapong likhitparinya le 25 Août 2019
Commenté : Steven Lord le 6 Jan 2021
I want to know the meaning of the MATLAB code line by line
command_output_1 =ssh2_simple_command(hostname,username,password,'grep
-h "mat water" ./RBWR_TB2_2019/RBWR_TB2_2019');
this line mean login to server and find the line with "mat water" and give that line equal to command_output_1, Am I right?
for m = 1:length(command_output_1)
Y1(m,1) = textscan(command_output_1{m},'%s');
end
1)This line is for m = 1 to the line of command_output_1
then read the what?
o = 75; %location where coolant density is located in input file
for n = 1:34
Y2(n,1) = str2num(Y1{o, 1}{3,1});
o = o+1;
end
2)This loop str2num is to change str to number, but I don't understand after str2num what is it do?
serpent_command = sprintf('cd RBWR_TB2_2019;printf "%s" "#PBS -l
nodes=n001:ppn=8+n002:ppn=8+n003:ppn=8+n004:ppn=8" "#PBS -V" %s
"/opt/serpent/serpent2/sss2 -omp 32 RBWR_TB2_2019 > screen_output" >
RBWR_TB2_2019.qsub;qsub RBWR_TB2_2019.qsub','%s\n','"cd
$PBS_O_WORKDIR"');
serpent_command = strrep(serpent_command,'"','''');
3) What are these line do? Is it run serpent ?
P.S. I have more code to read,if someone want to give me a contact maybe an email or line it's wil be very grateful.

Réponse acceptée

Walter Roberson
Walter Roberson le 25 Août 2019
this line mean login to server and find the line with "mat water" and give that line equal to command_output_1, Am I right?
Sounds reasonable -- but ssh2_simple_command is not part of MATLAB, so we do not know what the command does. Perhaps you are using https://www.mathworks.com/matlabcentral/fileexchange/35409-ssh-sftp-scp-for-matlab-v2
then read the what?
textscan() is always going to return a cell array.
With textscan() not having been passed any Delimiter or Whitespace options, and with one line at a time of the response being passed to textscan(), the effect will be that each Y1(m,1) entry will become a cell array of character vectors each of which is one "word" of the output of the line, where "word" is whitespace delimited. There are ways a lot more efficient than textscan() to achieve the same result.
This loop str2num is to change str to number, but I don't understand after str2num what is it do?
Notice the o=75 line. The o=o+1 line of code after the str2num() has the effect of moving on to column 76, 77, and so on, with o ending up as 109, after column 108 was converted. There are a lot more efficient ways of doing this too.
3) What are these line do? Is it run serpent ?
Not exactly. Those lines are preparing a shell command line for later execution, without executing it inside of what you posted so far. The shell command, when executed, would change directories, then create a file of qsub commands, and then invoke qsub to execute the commands, and then cd somewhere else. The shell command being created is to be executed by a Linux shell, it appears to me.
  2 commentaires
Thanapong likhitparinya
Thanapong likhitparinya le 12 Sep 2019
o = 75; %location where coolant density is located in input file
for n = 1:34
Y2(n,1) = str2num(Y1{o, 1}{3,1});
o = o+1;
end
So Y1{o ,1} it will convert the data of Y1{o,1} to number and keep it in Y2(n,1) %up to o=109% right? but what {3,1 }do?
Bruno Luong
Bruno Luong le 12 Sep 2019
Modifié(e) : Bruno Luong le 12 Sep 2019
pick the third word.

Connectez-vous pour commenter.

Plus de réponses (1)

parveen bano
parveen bano le 6 Jan 2021
'fitnet' requires deep learning toolbox
  2 commentaires
parveen bano
parveen bano le 6 Jan 2021
how can i remove this warning
Steven Lord
Steven Lord le 6 Jan 2021
Since this does not appear at all related to the original question, please post it as a separate question.

Connectez-vous pour commenter.

Tags

Aucun tag saisi pour le moment.

Community Treasure Hunt

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

Start Hunting!

Translated by