Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

could anyone help me to overcome the error in the following code

조회 수: 1 (최근 30일)
Prabha Kumaresan
Prabha Kumaresan 2018년 4월 5일
마감: MATLAB Answer Bot 2021년 8월 20일
Code:
list_of_rng_seeds = {[12, 2 ,1], [3, 4 ,5 ,6, 7],[8 ,9, 10]}
for seed_idx = 1 : length(list_of_rng_seeds)
list_of_rng_seed = list_of_rng_seeds{seed_idx}
for rng_usage_idx = 1 : length(list_of_rng_seeds)
this_seed = list_of_rng_seeds(rng_usage_idx)
fprintf('Below results are for rng = %d\n', this_seed);
rng(this_seed)
unused_rows = 1:4
while ~isempty(unused_rows)
N_UE_rows = 2
rows=unused_rows(randsample(length(unused_rows),N_UE_rows))
[~,idx]=find(ismember(unused_rows,rows))
unused_rows(idx)=[]
end
end
end
If i run the code i am getting Error using fprintf Function is not defined for 'cell' inputs. Error in line 10 fprintf('Below results are for rng = %d\n', this_seed); could anyone help me to overcome it.

답변 (1개)

Pawel Jastrzebski
Pawel Jastrzebski 2018년 4월 5일
편집: Pawel Jastrzebski 2018년 4월 5일
I believe that the 5ht line of code should be changed to (the variable without the -s):
this_seed = list_of_rng_seed(rng_usage_idx)
I can't check the rest of the code as I don't have the Statistical Toolbox. Also a piece of advice, it's probably not a good idea to have almost identical names for the variables:
  • list_of_rng_seed
  • list_of_rng_seed s

이 질문은 마감되었습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by