Abstracting info out of the filename and updating it

  • Thread starter apecher
  • Start date
In summary, a possible solution is to use an array instead of individual cell names to store the data and counts for each combination of H and T, and then use the "scatter" command to create the desired scatter plot.
  • #1
apecher
2
0
Following a similar problem that was posted...

I have data , which consists of 3 columns related to 3 parameters H, T and E (Height, period and efficiency) and herewith, I would like to create a scatter diagram.

the name of every cell would carry the name of the H and T parameter and that 'cell' should contain different efficiencies...

So:
- I managed to create a name for all these cells e.g.: Cell_H_T
for h=1:10
for t=1:10
eval(['Cell_' num2str(h) '_' num2str(t) '=[0]']);
end
end

Now:
- how can I adress every matrix individually?
In the next example, the number '1' (appearing in t1min) should also change in between each loop.
e.g.: I analyse the data and if the data follows the requirements I would like to add that value into the cell_H_T... and also count the number of datapoints in there countCell_H_T
(this off course doesn't work)
for h=1:10
for t=1:10
for k = 1:length(H)
if (T(k)>=t1min & T(k)<=t8max) & (h1min<=H(k) & H(k)<=h10max)
Cell_ num2str(h) _ num2str(t) = [Cell_ num2str(h) _ num2str(t);E(k)]
countCell_ num2str(h) _ num2str(t) = countCell_ num2str(h) _ num2str(t) + 1;
end
end
end
end

Many thanks in advance for your help!
 
Physics news on Phys.org
  • #2
A possible solution is to use an array instead of individual cell names. You can use the following code to create a 3-dimensional array that stores the data for each combination of H and T:data = zeros(10,10); %create a 10x10 matrixcounts = zeros(10,10); %create a 10x10 matrix to store the countsfor h=1:10 for t=1:10 for k = 1:length(H) if (T(k)>=t1min & T(k)<=t8max) & (h1min<=H(k) & H(k)<=h10max) data(h,t) = [data(h,t);E(k)]; %add the new data to the existing data in the matrix counts(h,t) = counts(h,t) + 1; %increment the count in the corresponding entry end end endendOnce you have the arrays set up, you can then use the "scatter" command to create the desired scatter plot.
 
  • #3


I would first suggest that the author consider using more descriptive and specific variable names, rather than just "H," "T," and "E." This will make it easier to understand and troubleshoot the code in the future.

In terms of addressing each matrix individually, the author could use a cell array to store all the different matrices, with each cell corresponding to a specific combination of H and T parameters. Then, they could use indexing to access and manipulate each matrix within the cell array.

As for the issue with the loop and changing the number in t1min, I would suggest using a variable to store the value, rather than hardcoding it into the loop. This way, it can be easily changed as needed.

Overall, I would also recommend breaking down the problem into smaller, more manageable steps and testing each step separately before combining them into the final code. This will make it easier to troubleshoot and identify any errors. Additionally, commenting the code and providing clear explanations of the steps being taken can also be helpful for understanding and debugging.
 

1. What does it mean to "abstract" information out of a filename?

Abstracting information out of a filename means to separate and extract specific data or details from the name of a file. This can be done programmatically by using certain rules or patterns to identify and isolate the desired information.

2. Why would someone want to abstract information out of a filename?

There are several reasons why someone might want to do this. One common reason is to organize and categorize files based on specific details, such as the date or author, contained within the filename. This can make it easier to search for and locate files in a large collection. Another reason may be to automate certain tasks or processes based on the information in the filename.

3. How is information typically abstracted out of a filename?

The process of abstracting information out of a filename can vary depending on the specific needs and goals of the user. However, it usually involves using some form of programming or scripting to analyze the filename and extract the desired information based on predefined rules or patterns. This may involve using regular expressions, string manipulation, or other techniques.

4. Can abstracting information out of a filename be done manually?

In some cases, it may be possible to manually abstract information out of a filename, especially if the file naming convention is consistent and follows a specific pattern. However, this can be a time-consuming and error-prone process, which is why it is often automated using programming or scripting.

5. Are there any limitations to abstracting information out of a filename?

Yes, there can be limitations to this process. For example, if the filename does not contain the desired information or if the information is not easily identifiable based on a consistent pattern, it may not be possible to abstract it. Additionally, the accuracy of the information extracted may depend on the quality and consistency of the file naming convention.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
2K
  • Atomic and Condensed Matter
Replies
3
Views
867
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
10K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
5K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
4K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
7K
Back
Top