Answered Essay: Current Folder file7.txt × + Name 1 30-39-48-1-10-19-28 2 38-47-7-9-18-27-29 3 46-6-8-17-26-35-37 4 5-14-16-25-34-36-45 5 13-15-24-33-42-

Create a hierarchy of folders and files

For this part, you are going to make repeated calls to the function mkdir as well as repeated file creations. Your objective is to start small, creating 3 directories (‘folders’) with 3 files, however you will need to automate the process so that you can quickly generate many directories and files. The directories you need to create are simply labelled ‘dir1’, ‘dir2’, etc, up to your maximum directory size n. Additionally, inside each of the n directories, you must place m files in TXT format labelled ‘file1.txt’, ‘file2.txt’, etc. The data inside each file must be a magic square of the label size (eg. ‘file7.txt’ contains a 7×7 magic square), with the numbers delimited by the dash character (‘-’). You can use the function magic() to quickly generate a magic square of any size.Current Folder file7.txt × + Name 1 30-39-48-1-10-19-28 2 38-47-7-9-18-27-29 3 46-6-8-17-26-35-37 4 5-14-16-25-34-36-45 5 13-15-24-33-42-44-4 6 21-23-32-41-43-3-12 7 22-31-40-49-2-11-20 file 1.txt file2.txt file3.tt file 1.txt 目file2.txt file3.tct 目file1.txt 目file2.txt 目file3.txt file 1.txt file2.txt 目file3.txt file1.txt file2.tt 目file3.txt 5420 2974-12 1753 23-23 1863 -12-319 5344 8-1-420 47-6234 3464123 e086-312 fil 3345122 1234567

by using matlab

the code

for i=1:n
Name=[‘dir’,num2str(i)];
mkdir(Name);
for j=1:m
M = magic(7);
Name1=[‘file’,num2str(j),’.txt’];
dlmwrite([Name,”,Name1],M,’-‘);
end
end

Current Folder file7.txt × + Name 1 30-39-48-1-10-19-28 2 38-47-7-9-18-27-29 3 46-6-8-17-26-35-37 4 5-14-16-25-34-36-45 5 13-15-24-33-42-44-4 6 21-23-32-41-43-3-12 7 22-31-40-49-2-11-20 file 1.txt file2.txt file3.tt file 1.txt 目file2.txt file3.tct 目file1.txt 目file2.txt 目file3.txt file 1.txt file2.txt 目file3.txt file1.txt file2.tt 目file3.txt 5420 2974-12 1753 23-23 1863 -12-319 5344 8-1-420 47-6234 3464123 e086-312 fil 3345122 1234567

Expert Answer

 

%Matlab program to create hierarchy of files and folders

n=input(‘n Enter the maximum number of directories:’); % input ‘n’ the number of directories to create
m = input(‘n Enter the maximum number of files:’); % input ‘m’ the number of files to create in each directory

% loop to create directories

for i=1:n
dir_name=strcat(‘dir’,num2str(i)); % initializing dir_name variable with the required name of the directory
mkdir(dir_name); % creating directories

% loop to create files in the directories
for j=1:m
file_name = strcat(‘file’,num2str(j),’.txt’);  % initializing file_name variable with the required name of the file
filename = fullfile(dir_name,file_name); % buildng full filename u.e directory name + file name
file = fopen(filename,’w’); %opening the file in write mode
dlmwrite(filename,magic(j),’delimiter’,’-‘); % write matrix magic(j) to ASCII-delimited file with delimiter ‘-‘   fclose(file); % close the file

end

end

Buy Essay
Calculate your paper price
Pages (550 words)
Approximate price: -

Help Me Write My Essay - Reasons:

Best Online Essay Writing Service

We strive to give our customers the best online essay writing experience. We Make sure essays are submitted on time and all the instructions are followed.

Our Writers are Experienced and Professional

Our essay writing service is founded on professional writers who are on stand by to help you any time.

Free Revision Fo all Essays

Sometimes you may require our writers to add on a point to make your essay as customised as possible, we will give you unlimited times to do this. And we will do it for free.

Timely Essay(s)

We understand the frustrations that comes with late essays and our writers are extra careful to not violate this term. Our support team is always engauging our writers to help you have your essay ahead of time.

Customised Essays &100% Confidential

Our Online writing Service has zero torelance for plagiarised papers. We have plagiarism checking tool that generate plagiarism reports just to make sure you are satisfied.

24/7 Customer Support

Our agents are ready to help you around the clock. Please feel free to reach out and enquire about anything.

Try it now!

Calculate the price of your order

Total price:
$0.00

How it works?

Follow these simple steps to get your paper done

Place your order

Fill in the order form and provide all details of your assignment.

Proceed with the payment

Choose the payment system that suits you most.

Receive the final file

Once your paper is ready, we will email it to you.

HOW OUR ONLINE ESSAY WRITING SERVICE WORKS

Let us write that nagging essay.

STEP 1

Submit Your Essay/Homework Instructions

By clicking on the "PLACE ORDER" button, tell us your requires. Be precise for an accurate customised essay. You may also upload any reading materials where applicable.

STEP 2

Pick A & Writer

Our ordering form will provide you with a list of writers and their feedbacks. At step 2, its time select a writer. Our online agents are on stand by to help you just in case.

STEP 3

Editing (OUR PART)

At this stage, our editor will go through your essay and make sure your writer did meet all the instructions.

STEP 4

Receive your Paper

After Editing, your paper will be sent to you via email.