English 中文(简体)
比较在实验室中长度相同的两种不同病媒
原标题:comparing two dissimilar vectors of same length in matlab

我有两个汇总表A和B。 A组长1 000X1,包括0分和1分,B也属同一规模。 现在B是作为投入开展全方位行动的职能的产出。 单单单是增加1个地方的零,因此B的数值与A相似,只有1个地方中的部分被0个点取代。 现在,我的任务是填充在B的零数值,这些数值在穿透后以随机的双币值取代。 在用户帮助下,我完成了这项工作。 而《法典》也在这里。

idx=strfind(B,[0 0 0 0]);
n=dec2bin(randi([0 15],[numel(idx) 1]),4) -  0 ;
idx=bsxfun(@plus, idx , (0:3));
xx = B;
xx(idx(:)) = n(:);

现在,这一职能还将取代A部分已经存在的零。 我只想取代从1至0的零,而不是A中已经零的零。 任何帮助都将受到高度赞赏。

问题回答

我将这样做:

function modifiedB=modifyB(A,B)
  idx=(A~=B); %% or idx=((A==1)&(B==0)); %% find the indices where B changed
  B(idx)=(rand(nnz(idx),1)>0.5); %% replace at those indices by random numbers
  modifiedB=B;
end




相关问题
Find the closest time from a list of times

So, here s the scenario. I have a file with a created time, and I want to choose a time from a list of times that that file s created time is closest or equal too...what would be the best way to ...

PHP Comparison Operators and Data Types

I m currently working through O Reilly s "Programming PHP" and have come across this table titled "Type of comparison performed by the comparison operators": First Operand | Second ...

Loop Until Condition Reached, iPhone

I have a problem here... After a button is pressed I want a loop to run until a condition is reached: - (IBAction)buttonclick1 ... if ((value2ForIf - valueForIf) >= 3) { ... I would like a loop ...

nuSoap or Zend Soap? [closed]

I would like to know the differences between nusoap and ZendSoap, which is the best? what benefits and disadvantages of each? Anyone who has used both technologies could make this comparison? Thank ...

Logic for a file compare

I trying to write a programm for file compare. For example: file1 1 2 3 4 5 file2 1 2 @ 3 4 5 If I do it line by line, I get: 1 == 1; 2 == 2; 3 != @; 4 != 3; 5 != 4; != 5; But, the truth is ...

热门标签