Okay, so my problem is pretty basic but I just cant solve it. My basic Problem im trying to solve is as follow: I get different sets of data i want to plot, which means i have x and y data, but sometimtes i only have one set of data sometimes i have 4. I have written an for loop to plot every set in a different color etc.. Until now everyting works fine.
Now to my problem: Only a specific range of values are interesting for me, the ones from 1<=x<=4. I Still want to plot all data but only this range should be in color.
- I tried achivieng this directly in the plot info but it didnt work and found some similar question online where someone suggested to just split ur array. So im looking for the index in my x array where the value first goes over 1 and the index where it first get over 4. I need the index bc i need to split my y accordingly. First question here is. How can i just get every index? My data is not linear which means after my first value of 1.002 i may get another 0.998.. I would like to have all of the indices that have a value between 1 and 4.
idx_min{i} = {find(x_all{i}>=1,1)}
idx_max{i} = {find(x_all{i}<=4,1)}
This is what i do until now.. which means for each Set of Data created in the loop (x_all{i} with i the number of data setsif finds me the first index of an value above 1 and under 4. I tried combining the two for all values but i constantly get the invalif use of operator error.
2. But even if i have the first and last indicies i cant create a new cell array that contains all the values of my first array within my 2 indices. For calification i have an
example.
for i = 1:number_of_data_sets
set{i} = 1:number_of_data_sets
set{i} = (data.x(i)value data.y(i).value]
idx_min{i} = {find(x{i}>=1,1)}
idx_max{i} = {find(x{i}<=4,1)}
x_relevant{i} = x{i}(idx_min{i}:idx_max{i}) %this should take my x array with the values from my minimum index to the maximum index but i get Undefined operator ':' for input arguments of type 'cell'.
Im pretty new to matlab and im getting consufesed with the index of my loop, the index of the arrays created in the loop and the index of my values.
0 Comments
Sign in to comment.