F = zeros(20,1);
F(1:4) = 3.3;
F(5:7) = 4.2;
F(8:10) = 1.8;
F(11:13) = 6.9;
F(14:17) = 4.3;
F(18:20) = 4.1;
how do i take these and put it into the matrix

댓글 수: 3

DGM
DGM 2022년 11월 26일
What exactly do you want? The given code will give you a 20x1 vector. There isn't a clear pattern to the vector generation. It's just some arbitrary blocks of some arbitrary constants. If you want to programmatically generate something, it's up to you to describe the inputs and outputs.
John D'Errico
John D'Errico 2022년 11월 26일
Those numbers are already in a matrix, a 20x1 matrix, usually called a vector, but still a matrix too. So exactly what do you want?
poppy
poppy 2022년 11월 26일
well I would like to display al lthose numbers from 1-20 using fprintf or a table how would I go about doing that?

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

답변 (1개)

Walter Roberson
Walter Roberson 2022년 11월 26일

0 개 추천

F = zeros(20,1);
F(1:4) = 3.3;
F(5:7) = 4.2;
F(8:10) = 1.8;
F(11:13) = 6.9;
F(14:17) = 4.3;
F(18:20) = 4.1;
table(F)
ans = 20×1 table
F ___ 3.3 3.3 3.3 3.3 4.2 4.2 4.2 1.8 1.8 1.8 6.9 6.9 6.9 4.3 4.3 4.3
fprintf('%.1f\n', F)
3.3 3.3 3.3 3.3 4.2 4.2 4.2 1.8 1.8 1.8 6.9 6.9 6.9 4.3 4.3 4.3 4.3 4.1 4.1 4.1

카테고리

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

제품

릴리스

R2021b

태그

질문:

2022년 11월 25일

답변:

2022년 11월 26일

Community Treasure Hunt

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

Start Hunting!

Translated by