Script that performs the same as MATLAB function.
Mostra commenti meno recenti
I am looking to create scripts for some internal functions: repmat, fliplr, flipud, and rot90. I am familiar with how each works but I am not sure where I should start. I have two of the four below.
%This script will perform the same operation as rot90
x = input('Enter the matrix: ');
[m,n] = size(x);
[i,j] = length(x);
y = input('Which direction to rotate the matrix\nEnter -90 or 90: ');
newvec = 0; %This is the variable for the result
if y == -90
%rotate counterclockwise
elseif y == 90
%rotate clockwise
end
%This script will duplicate the user entered matrix and create a new matrix
%by the number of rows and columns specfied by the user.
mat = input('Enter your matrix: \n');
rows = input('Enter number of rows: \n');
cols = input('Enter number of columns: \n');
newvec = zeros(rows,cols,mat);
8 Commenti
Walter Roberson
il 4 Ago 2015
newvec = zeros(rows,cols,mat); is going to be rejected unless mat is entered as a scalar by the user.
Walter Roberson
il 4 Ago 2015
It is not clear what you are asking? What assistance are you hoping for from us?
If you are looking for information on the algorithm to implement these functions: figuring that out is most of the work of the homework assignment.
Hint: look at "for" loops.
David Hughes
il 4 Ago 2015
Modificato: Walter Roberson
il 4 Ago 2015
David Hughes
il 4 Ago 2015
Modificato: Walter Roberson
il 4 Ago 2015
Walter Roberson
il 4 Ago 2015
Are you getting an error message with that second script?
David Hughes
il 4 Ago 2015
Steven Lord
il 4 Ago 2015
And the full text of the error message you receive from your repmat-like script is ... ?
[BTW, I'm assuming you're doing this for homework. If not, I recommend you simply use the functions included with MATLAB.]
David Hughes
il 4 Ago 2015
Modificato: Walter Roberson
il 4 Ago 2015
Risposte (0)
Categorie
Scopri di più su Creating and Concatenating Matrices in Centro assistenza e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!