Do you still think using structs is a good approach for that? Please ask me for clarifications if necessary.Suppose that C is a cell array with shape M × 1 (i.e., size(C) returns ), and that each element of C is in turn a cell array with shape 1 × N. My implementation sounds complicated but what I really do is quite simple. After that, I need to search the profile struct (timestep_struct(t).profile=profile ), search within every array of that, to find an id (remember we have arrays of Mx3 where the first column is id and the second is a number to be reduced) in other timesteps other than t, and reduce their number by 1. So,zero positions in the cell array have been reduced by one and the position marked as 1 will be no longer be used. When i find the coordinates that give me maximum util, I set that position in the cell array to 1. ![]() For each zero position I find the corresponding value from the struct and perform the black box operation. ![]() The way I am doing all this now, is by initializing a cell array having the dimensions of timestep_struct with zero at each position. Function printTrajectory 5 The function printTrajectory (lines 9-16) takes an input argument Traj, a cell array containing the trajectory information. And if I want to replace a value of an array, i mean, in this case B 3 2 1 0, and C should find the values that match from A, A variates between 3 and 0 like randi function, so how D can use cellfun for search in A the values that match and replace with another values. Then, i will run the same operation again to find the next best configuration. One of this timestep_struct(i).coordinates(j,:) will give me the maximum utility after the processing. Say t can take values from 1 to 120, and each coordinates matrix may have from 1 to 100 rows (each matrix can have different number of rows). For extracting subsets of cells you need to use round parentheses. Basically, the purpose of curly braces is to retrieve the underlying content of cells and present a different behavior. Best would be to leave it as a numeric array. When i try to multiply these arrays like this H.X i get the following error: Undefinedoperator. You have to use round parentheses indexing instead of curly braces indexing, like this: data (:,1) Output: ans 3×1 cell array first second third. ![]() This will be used in let's say black box operation. Hello, i want to multiply an array H which is 2x2 cell array (each cell contains a 1x500 array) with an array X which is 2x1 array (also each cells contains 1x500 array). A cell2mat (C) converts a cell array into an ordinary array. The files contain the results of a simulation with variing parameters and there are 30 different values for each run, stored in 3 different files for each run. What i want to do, is to iterate through timestep_struct(t) selecting one row of coordinates at a time. txt files into Matlab and the data is stored in cell arrays (I found a tutorial that used this way). "points" is a 2 columned matrix with N rows. profile for each iteration t, is an array like. ![]() Where it is populated inside a for loop which is fast enough.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |