我想生成一个具有重复增量的连续数字,例如从1到3。重复的增量为1(x 5)。这样的输出将是。
输出=
[1
1
1
1
2
2
2
2
2
3
3
3
3
3]
5次重复1,然后5次重复2,依此类推。
我尝试了以下代码:
a = [1:1:3]
for i = a(:,1:end)
disp(i+zeros(5,1))
end
我得到了相同的结果,但是,我不能将输出放在一列中。感谢您的帮助。
答案 0 :(得分:3)
让我们
@Override
public void onBindViewHolder(@NonNull final PostViewHolder postViewHolder, int i) {
Resources resources = Home_Activity.getResources();
StorageReference storageReference = FirebaseStorage.getInstance().getReference();
storageReference.child("images/-LgXJiSUo44zOIzky-eZ.jpeg");
storageReference.getDownloadUrl().addOnSuccessListener(new OnSuccessListener<Uri>() {
@Override
public void onSuccess(Uri uri) {
postViewHolder.picture.setImageURI(uri);
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Toast.makeText(Home_Activity, e.getLocalizedMessage(), Toast.LENGTH_SHORT).show();
}
});
postViewHolder.name.setText(posts.get(i).getPlace_name());
postViewHolder.description.setText(posts.get(i).getPlace_detail());
}
有两个选择
n = 3; % number of distinct numbers
s = 2; % starting number
m = 5; % number of repetitions of each number
或
output = repelem(s:s+n-1,m);