In my case
>> U
U =
1×2 cell array
[1×2 double] [1×2 double]
>> U{1}
ans =
1 2
>> U{2}
ans =
2 3
F = { } ;
How can I obtain F like that?
F = { {1 2} { 2 3} }

답변 (1개)

Guillaume
Guillaume 2019년 11월 25일

1 개 추천

If you're asking how to transform U into your desired F:
F = cellfun(@num2cell, U, 'UniformOuput', false);
would be one way of doing it.
However, making a cell array of scalar numbers (e.g. {1, 2}) is rarely a good idea. It uses a lot more memory and is more complicated to use.

댓글 수: 4

Mira le
Mira le 2019년 11월 25일
I want F to be like that F = { {1 2} {2 3}, {2 3 }, {1 2} }
Guillaume
Guillaume 2019년 11월 25일
You need to explain the starting point and probably explain the reasoning behind your question.
...and make sure you're actually asking the right question since you've now moved the goalpost.
Right now it looks like the answer to your question: "I want F to be like that F = { {1 2} {2 3}, {2 3 }, {1 2} }" is to simply type:
F = { {1 2}, {2 3}, {2 3 }, {1 2} }
in your code. Hopefully, that's not what you're asking.
Mira le
Mira le 2019년 11월 25일
I just forgor to make the right F in the first
Guillaume
Guillaume 2019년 11월 25일
I still have no idea what you're asking since you haven't even explained what we start with and what you're trying to do.

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

카테고리

도움말 센터File Exchange에서 Logical에 대해 자세히 알아보기

제품

릴리스

R2017a

질문:

2019년 11월 25일

댓글:

2019년 11월 25일

Community Treasure Hunt

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

Start Hunting!

Translated by