How to construct a 3D matrix from a 2D matrix

1 ビュー (過去 30 日間)
Enrico Scupola
Enrico Scupola 2018 年 5 月 20 日
編集済み: dpb 2018 年 5 月 21 日
Hi all, I am struggling to find a solution to this problem. I am not very skilled with 3D matrices and my MATLAB coding skills are worse than I thought. So the problem is as follow. I have a 5-column matrix made of patent number, application year, category (ranging from 1 to 6), subcategory (ranging from 1 to 36) and assignee number. So for each assignee number I have many patents denoted by the patent number. Now I want to construct a 3D matrix out of the matrix I just described having the years on the rows or first dimension, the subcategory on columns or second dimension and the assignee number on pages or third dimension. In each cell I would like to have the amount of patents a company has. In other words, the sum of rows per each assignee number.
I am stuck at the very beginning and I don't know where to begin the loop.
Many thanks.
  5 件のコメント
dpb 2018 年 5 月 21 日
編集済み: dpb 2018 年 5 月 21 日
OK, got it...Firstly, I'd convert to categorical(*) variables instead of strings; will be much easier to do lookups and comparisons that way as well as be less memory-intensive if the tables are large as indicate; before go too far, what's with the minus signs at the beginning of B array first column for assignee--that have some significance?
I've not had time to actually do more than look a little, sorry, but I'm thinking probably using tables and grouping variables will let you do the lookups you're after rather than building this alternate array (esentially it is the array, but would be in table form and use grouping variables to do the construction behind the scenes).
The first step along my idea would be something like-
Example to see where we start from--
>> C(1:10,:)
ans =
10×4 table
Patent Year Subcategory Assignee
_______ ____ ___________ ________
3930271 1974 6 63
3930272 1974 6 65
3930273 1975 6 65
3930273 1975 6 65
3930276 1972 6 69
3930277 1974 6 69
3930280 1974 6 69
3930280 1974 6 69
3930281 1974 6 69
3930282 1974 6 61
The above raises another question--why are there duplicated rows in C? 3930273 is there twice with identically same data for all fields...
(*) Or, if the codes are and always will be all numeric, could use integer.


回答 (0 件)





Community Treasure Hunt

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

Start Hunting!

Translated by