will creating a variable map(i,j) = {array} (this is inside two for loops) create a variable that has i locations with unique locations j inside i?

1 for i = 100:100:500
2 A = load('data_i', 'gotcha');
3 B = load(data_i+100, 'gotcha');
4 gotcha1 = A.gotcha;
5 gotcha2 = B.gotcha;
6 length = size(unique(gotcha1)) - 1;
7 for j = 1:length
8 map(i/100,j) = {unique(gotcha2(gotcha1 == j))};
9 end
10 end
In line 8 will this varible create basically a dictionary inside a dictionary?

댓글 수: 4

Dunno what you meah by "dictionary" here...
You would create a cell array of 5xlength each element of which containing the output of the call to unique...with the caveat that the number of columns in the array map will be the value of the maximum that length will have been over the loop on i. You will end up with empty cells in those locations for which i,j is not covered.
Also, do NOT use "length" as a variable; it's a builtin MATLAB function.
It's not in a toolbox I have so not sure, but I'd guess there's a good chance that map is used in one or more toolboxes as well...
Please attach your .mat files. Use the paper clip icon to attach data_i.mat, and for line 3, that won't work because the first argument has to be your .mat filename. Your code will create a cell array with 5 rows and however many unique numbers are in the row with the most unique numbers in array gotcha2. I have no idea what you're after here. It would be good for you to attach the .mat files, and say what you'd like map to be after the code finishes.
thisfile = sprintf('load_%d.mat', i);
nextfile = sprintf('load_%d.mat', i+100);
A = load(thisfile, 'gotcha');
B = load(nextfile, 'gotcha');
Yes these answers helped me figure it out thanks you everyone!

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

도움말 센터File Exchange에서 Image Processing Toolbox에 대해 자세히 알아보기

태그

질문:

2020년 7월 21일

댓글:

2020년 7월 22일

Community Treasure Hunt

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

Start Hunting!

Translated by