How to multiply a matrix by 0?

Hello,
I have this file in .txt and i want to make a matrix and multiply it by 0 using matlab!
Can somebody help me? I've been looking at other videos and answers but can't work it out. Thanks!

답변 (1개)

Sulaymon Eshkabilov
Sulaymon Eshkabilov 2023년 2월 15일

0 개 추천

Why to muply the matrix by zero when the resul;t will be a matrix of the same size with zeros. If you need to create a matriz of the same size as your data, then this is the way:
clearvars
unzip('HSF_PVerde_Lvl1.zip');
D = readmatrix('HSF_PVerde_Lvl1.txt');
D0 = zeros(size(D)); % This is the way
D0A = D*0;
whos
Name Size Bytes Class Attributes D 160128x12 15372288 double D0 160128x12 15372288 double D0A 160128x12 15372288 double
D0
D0 = 160128×12
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
D0A
D0A = 160128×12
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

댓글 수: 1

Why to muply the matrix by zero when the resul;t will be a matrix of the same size with zeros.
Most of the time that's correct. If nonfinite values are involved it's not.
A = [1 2 0; NaN Inf -Inf]
A = 2×3
1 2 0 NaN Inf -Inf
B = 0*A
B = 2×3
0 0 0 NaN NaN NaN

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

카테고리

도움말 센터File Exchange에서 Logical에 대해 자세히 알아보기

질문:

2023년 2월 15일

댓글:

2023년 2월 15일

Community Treasure Hunt

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

Start Hunting!

Translated by