필터 지우기
필터 지우기

replacing zeros with one and storing it in matlab

조회 수: 3 (최근 30일)
Elaf Trabulsi
Elaf Trabulsi 2019년 12월 9일
편집: Adam Danz 2019년 12월 13일
hi i want to display a zero matrix (10x10)
then i want to ask the user to select a specific row and column and then whatever the user selects will turn into 1.
example:
1 2 3 4 5 6 %where 1-6 are columns and A is the name of row
A 0 0 0 0 0 0
user will select: A,4
then the above will change into the following:
1 2 3 4 5 6
A 0 0 0 1 0 0
so that when the user enters again, this will be stored
for example second time user enters will look like this:
user will select: A,2
then the above will change into the following:
1 2 3 4 5 6
A 0 1 0 1 0 0
  댓글 수: 1
Adam Danz
Adam Danz 2019년 12월 9일
편집: Adam Danz 2019년 12월 13일
How are you getting this data from the user? A gui? Using input()?
What are the variable names that store the 10x10 sparse matrix, the column numbers and row letters?
Are your 1s and 0s double or logical?

댓글을 달려면 로그인하십시오.

답변 (1개)

Roshni Garnayak
Roshni Garnayak 2019년 12월 13일
Let the zero matrix be A and the row number is assigned to a variable x. Then the following piece of code can help you convert the entire row into ones:
A(x, :) = 1;

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by