A vector with interchangeable numbers?
显示 更早的评论
I am trying to make a vector with 10 individual numbers. These numbers can be either 1 or 0 as 'yes' or 'no'. The probability of it being a yes or a no will be dependant on many other probabilities I will be factoring in, but how can I build this initial set that won't deviate from the initial rules? I will always be working with this vector but changing around the probabilities. I see a number of methods to achieve this, but there must be a single best way. I am currently writing this initial vector as a script and will incorporate the other rules as individual scripts. Examples of what I have already made are;
clear all; % Clear the workspace
clc; % Clear the command window
ev = [0 0 0 0 0 0 0 0 0 0];
evA = categorical(ev,[1 0],{'international','domestic'});
But this is just for categories?
Or cell arrays?
c = cell(1,10)
c = [] [] [] [] etc
deal function
[c1{0-1]} = deal (0)
and then I can refer to the vector as a whole (c1-c10) or individually (c1)??
There must be a better way?! Thanks!
1 个评论
José-Luis
2017-9-11
I don't get it. What's wrong with a logical array? What are these rules?
回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Multidimensional Arrays 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!