How can I replace every element of a matrix with a special character to hide the element

1 次查看(过去 30 天)
I have a nxn matrix and want to hide the elements and replace them with a special character
Example
1 2 3
4 5 6
7 8 9
is now
* * *
* * *
* * *

采纳的回答

Rick Rosson
Rick Rosson 2015-11-29
x = magic(3);
y = repmat('*',size(x));
disp(y);

更多回答(2 个)

Rick Rosson
Rick Rosson 2015-11-27
x = magic(3);
x(x<7) = NaN;
disp(x);

Image Analyst
Image Analyst 2015-11-27
Try this, using fprintf():
m = [...
1 2 3
4 5 6
7 8 9]
[rows, columns] = size(m);
for row = 1 : rows
for col = 1 : columns
fprintf('* ');
end
fprintf('\n');
end
and this.

类别

Help CenterFile Exchange 中查找有关 Matrix Operations and Transformations 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by