how to convert 1x2 double into two 1x1

조회 수: 27 (최근 30일)
flashpode
flashpode 2021년 10월 23일
댓글: flashpode 2021년 10월 25일
Hi I was coding when I had this error:
Time_msg_match = string(Time_msg_match);
Error using string
Conversion from cell failed. Element 61649 must be convertible to a string scalar.
>> Time_msg_match(61649)
ans =
1×1 cell array
{2×1 double}
How can I concadenate this 2x1 double?
I wrote:
Time_msg_match1 = num2str(cat(1, Time_msg_match{:}));
But the result is not what I wanted. Thanks in advance

채택된 답변

Image Analyst
Image Analyst 2021년 10월 23일
Try this to create 2 separate variables out of that 1x2 cell array
Time_msg_match1 = Time_msg_match{1};
Time_msg_match2 = Time_msg_match{2};
  댓글 수: 6
flashpode
flashpode 2021년 10월 25일
I did not get what you tried to do but look what I have when I code
>> Time_msg_match = Time_msg_match';
>> Time_msg_match = string(Time_msg_match)
Error using string
Conversion from cell failed. Element 61649 must be convertible to a string scalar.
>> Time_msg_match(61649)
ans =
1×1 cell array
{2×1 double}
flashpode
flashpode 2021년 10월 25일
But I have deleted this line and it has worked so it is resolved. Thank you. Now I want to use this to index a duration array but I am gonna look by myself to do this. Once again thank you!!!!!

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

추가 답변 (1개)

Rik
Rik 2021년 10월 23일
It looks like this is what you want:
x=Time_msg_match(61649);
x=x{1};
  댓글 수: 7
Image Analyst
Image Analyst 2021년 10월 24일
@vicente Noguer, did you overlook my request?
Also, a specific numerical example using the first 2 or 3 rows of your cell array would be helpful. Help us to help you.
Rik
Rik 2021년 10월 24일
You are ignoring the advice that Image Analyst is giving you. That is not smart.
Also, did you try making a it a double array instead of a cell? You will notice that my code will still do something usefull. It brings you only a single step away from the array you need.

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

카테고리

Help CenterFile Exchange에서 Data Type Conversion에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by