I am struggling with this problem for a day and cannot find a solution anywhere online. I have four cell arrays with data per country on which I perform operations to find a number of countries that I want to analyse. I have saved these countries in a 27x1 cell array with nonnumerical attributes whose output looks like:
'Belgium'
'Bulgaria'
'Croatia'
'Cyprus'
'Czechia'
'Denmark'
'Estonia'
This is an example of the rows that I want to subtract from other cell arrays with data per country. The problem is that cell arrays do not allow indexing which means that I cannot use these to subtract data from other cell arrays. So what I want as output is an array that allows indexing such that I can use that array to subtract information of other cell arrays.
What I have tried:
- I have tried str2double to create rows that allow indexing. This resulted in NaN values which did not allow any operation
- I have tried cell2mat which gave the error: Dimensions of arrays being concatenated are not consistent.
- I have tried to create a table from cell arrays, but I couldent paste all the data in it from the different cell arrays because I couldent subtract it
I am new here so I dont know how I can append my .m file and cell arrays. Therefore, I add a part of my code here:
[~,ia,ib] = intersect(pop(:,1),gdp(:,1));
Com_popgdp = [pop(ia,1:2),gdp(ib,2)];
[~,ia,ib] = intersect(fp(:,1),lr(:,1));
Com_fplr = [fp(ia,1:2),lr(ib,2)];
[~,ia,ib] = intersect(Com_popgdp(:,1),Com_fplr(:,1));
Com_all = [Com_popgdp(ia,1:2),Com_fplr(ib,2)];
Com_all = Com_all(:,1);
%Com_all is the resulting cell array with all countries that I want to
%analyse resulting from the intersections of cell arrays. For the analysis,
%I must extract the Com_all rows from
%pop/gdp/fp/lr. However, this is not possible with cell arrays. How can I
%access and extract the rows from pop/gdp/fp/lr for my analysis?
Could anyone help me find a way in which I can use the selection cell arrays as indexing to subtract data from other cell arrays? Which method would be appropriate?
tsv2cellfunction in Matlab and from then I use standard Matlab operations.