what does this mean ?

6 ビュー (過去 30 日間)
Alisha Ali
Alisha Ali 2015 年 5 月 2 日
回答済み: Thomas Nguyen 2018 年 4 月 5 日
a function takes two inputs: a matrix N and a scalar n, in that order, where each dimension of N is greater than or equal to n. The function returns the n-by-n square array at the bottom left corner of N.
  1 件のコメント
Joshua Sampson
Joshua Sampson 2017 年 2 月 22 日
編集済み: Joshua Sampson 2017 年 2 月 22 日
A function that that takes two inputs: a matrix N and a scaler n, in that order: function(N,n).
Where each dimension of N is greater than or equal to n: the dimensions of matrix N are at least n, so matrix N is at least n x n, i.e. if n = 3, matrix N is at least 3 x 3.
The function returns the n-by-n square array at the bottom left corner of N: if n = 3, the function will return a 3x3 matrix starting in the bottom left corner.

サインインしてコメントする。

回答 (2 件)

Azzi Abdelmalek
Azzi Abdelmalek 2015 年 5 月 2 日
編集済み: Azzi Abdelmalek 2015 年 5 月 2 日
Your function is doing this
A(end-n+1:end,1:n)
  2 件のコメント
Alisha Ali
Alisha Ali 2015 年 5 月 2 日
so i have tried this but getting an error from the solver
function N = bottom_left(N,n)
N(end-n+1:end,1:n)= n
end
Azzi Abdelmalek
Azzi Abdelmalek 2015 年 5 月 2 日
You don't need to create a function
N=[1 2 3 ;5 6 7;8 9 10]
n=2
out=N(end-n+1:end,1:n)

サインインしてコメントする。


Thomas Nguyen
Thomas Nguyen 2018 年 4 月 5 日
Code:
function[N] = forfun(N,n)
% N=[1 2 3 4 5;6 7 8 9 10;11 12 13 14 15]
% n=2
a=size(N);
for i=(a(1)-n+1):a(1)
for j=1:n
N(i,j)=n;
end
end
Usage:(preferred) Enter the N matrix in the command window (there's a sample N commented in the code) -> enter n in the command window, run forfun(N,n) in the command window.

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by