필터 지우기
필터 지우기

Help with creating an array!!

조회 수: 2 (최근 30일)
Marnie
Marnie 2015년 4월 3일
편집: Mahdiyar 2015년 4월 3일
So I want to create a single column vector with N number of rows. N being a user input number. I want to have 100 and 200 as the first and last numbers but have zeroes as all the rest...
so for a 5,1 vector it would be:
100
0
0
0
200
thanks

채택된 답변

Mahdiyar
Mahdiyar 2015년 4월 3일
편집: Mahdiyar 2015년 4월 3일
Hi you can use this code
N = input('Enter the value for N\nN = ');
Matrix = zeros(N, 1);
Matrix(1) = 100;
Matrix(end) = 200;

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by