how to create a combination of excel values in matlab

조회 수: 1 (최근 30일)
PA
PA 2023년 7월 3일
편집: dpb 2023년 7월 8일
I have an excel sheet. And i created an export folder . Later i want to import that combination in GUI.

답변 (2개)

dpb
dpb 2023년 7월 3일
M=[35 10 2;48 20 23].';
[m,b,e]=ndgrid(M(1,:),M(2,:),M(3,:));
v=arrayfun(@(m,b,e)m.*b.^e,m(:),b(:),e(:))
v = 8×1
1.0e+31 * 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 2.9360 4.0265
Surely an exponent of ^23 is a mistake...
  댓글 수: 5
dpb
dpb 2023년 7월 7일
편집: dpb 2023년 7월 7일
Well, can't do that to a table, but we've no idea what you're trying to do with just one line in isolation...what the answer illustrates is the answer to the Q? originally posted, but <you've got to dereference the table> to get the array values. table
It doesn't help that you also wiped out the original posting so now there's absolutely no context for any of the conversation.
Restore the original Q? and show your work that led to the problem.
PA
PA 2023년 7월 7일
i want to create a combinations from the table as shown in the I column.

댓글을 달려면 로그인하십시오.


dpb
dpb 2023년 7월 8일
편집: dpb 2023년 7월 8일
t=array2table([8 8 1;11 11 2].','VariableNames',{'V1','V2'}); % simulate table (next time attach the file)
M=[t.V1 t.V2]; % extract array from table
%M=t{:,end-1:end}; % ditto, alternative syntax
ii=[kron([1;4],ones(4,1)) repmat([2 3;2 6;5 3;5 6],2,1)]; % construct indices into array
M(ii) % create pattern via indices
ans = 8×3
8 8 1 8 8 2 8 11 1 8 11 2 11 8 1 11 8 2 11 11 1 11 11 2
I don't see a combinatoric that does what you're asking for otomh...may be one, but it's not apparent to me how to generate it other than brute force...
Next time you want to ask a Q?, though, attach the data to go with it; images are not a substitute except when it is a visual effect one is trying to match or the like; it's much more likely to get help if folks don't have to create test case data in order to work on your problem. "Help us help you!!!"
And don't edit away the original; add comments if needed, or amplify, but don't destroy the context. Most won't bother after such...

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by