布尔跟随指针和数字元素
我正在尝试使用布尔标志来确定需要加载哪些数据。例如,我有 5 个数据集,我使用 MATLAB 数组中的指针按能量对它们进行排序。我必须连接两个具有以下顺序的数据集:order =[5 2 3 4 1]
这意味着如果我必须使用 1 个数据集,布尔值将是
b= [ 0 0 0 0 1] % the fifth data set will de loaded
Power_load_1 = calculalation_X *b=0
to
Power_load_4 = calculalation_X *b=0
Power_load_5 = calculalation_X *b= a result
如果必须加载 2 个数据集:
b= [ 0 1 0 0 1]
Power_load_1 = calculalation_X *b=0
Power_load_2 = calculalation_X *b= a result
Power_load_3 and 4 = calculalation_X *b=0
Power_load_5 = calculalation_X *b= a result
我尝试使用 b=true(order(1,1:nbr_load))
,但结果是看来
5×2 logical array
b =
1 1
1 1
1 1
1 1
1 1
问题的根源在于它
order(1,1:nbr_load)
ans =
5 2
是一条将 5 行形成 2 列的指令,我不想要
它如何生成我的布尔值?
I'm trying to use boolean flags to determine which data needs to be loaded. For example, I have 5 data sets and I ordered them by energy with a pointer which is in an array in MATLAB. I have to connect 2 data sets which have the following order: order =[5 2 3 4 1]
That means if I have to use 1 data set the boolean will be
b= [ 0 0 0 0 1] % the fifth data set will de loaded
Power_load_1 = calculalation_X *b=0
to
Power_load_4 = calculalation_X *b=0
Power_load_5 = calculalation_X *b= a result
If 2 data sets must be loaded:
b= [ 0 1 0 0 1]
Power_load_1 = calculalation_X *b=0
Power_load_2 = calculalation_X *b= a result
Power_load_3 and 4 = calculalation_X *b=0
Power_load_5 = calculalation_X *b= a result
I tried to use b=true(order(1,1:nbr_load))
, but this results in
5×2 logical array
b =
1 1
1 1
1 1
1 1
1 1
it seeems the origin of the problem is this
order(1,1:nbr_load)
ans =
5 2
It is an instruction to form 5 lines to 2 columns, which I do not want
How can I generate my booleans?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我将使用一个简单的循环
order
进入逻辑数组b
,使用1:ii
从order中选择相关元素
:I'd use a simple loop over
order
into a logical arrayb
, using1:ii
to select the relevant elements fromorder
: