Please Explain this code
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
clc;
clear all;
close all;
x=1:1:10;
y=5:5:50;
z=x.*y;
fprintf('%i\t',x);
fprintf('\n');
fprintf('%i\t',y);
fprintf('\n');
fprintf('%i\t',z);
0 commentaires
Réponses (1)
Sriram Tadavarty
le 4 Avr 2020
Hi Caitlin,
Here is the annotated code with the explanation:
clc; % Clear command window
clear all; % Clears all the variables in the memory
close all; % Closes all the opened figures
x=1:1:10; % Defines a variable x from 1 to 10, in steps of 1 (i.e. 1, 2, 3, ..., 9, 10)
y=5:5:50; % Defines a variable y from 5 to 50, in steps of 5 (i.e. 5, 10, 15, ..., 45, 50)
z=x.*y; % Performs element wise matrix multiplication for x and y (i.e. (1*5), (2*10), (3*15), ..., (9*45), (10*50)), and assigns to z
fprintf('%i\t',x); % Prints the values in x with a tab spacing mentioned with \t
fprintf('\n'); % Prints a new line
fprintf('%i\t',y); % Prints the values in y with a tab spacing
fprintf('\n'); % Prints a new line
fprintf('%i\t',z); % Prints the values in z with a tab spacing
Hope this helps.
Regards,
Sriram
0 commentaires
Voir également
Catégories
En savoir plus sur Matrix Indexing dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!