Question

i have a cell u(38,1) each row has string looking like this : for example u{​​​​​1,1}​​​​​...

i have a cell u(38,1) each row has string looking like this : for example

u{​​​​​1,1}​​​​​ = ''198823 765389 white''

u{​​​​​2,1}​​​​​ = ''198426 725312 black''

I want the cell u to be divided in 3 colomns such as

u{​​​​​1,1}​​​​​ = ''198823'' u{​​​​​1,2}​​​​​= ''765389'' u{​​​​​1,3}​​​​​=''white''

u{​​​​​2,1}​​​​​ = ''198426'' u{​​​​​2,1}​​​​​= ''725312'' u{​​​​​2,3}​​​​​=''black''

so basically I want my u(38,1) to become u(38,3)

I have tried strplit, but it seems like it won't work with a cell,

strplit(u,',') %doesn't work'

strplit(u{​​​​​1,1}​​​​​,',') %works on the first line and returns a cell (1,3)

Homework Answers

Answer #1

%simplest solution is using a for loop to split one by one

clear
clc
u{1,1}="198823 765389 white";
u{2,1}="198426 725312 black";
for i=1:length(u)
tokens=strsplit(u{i});
u{i,1}=tokens(1);
u{i,2}=tokens(2);
u{i,3}=tokens(3);
end
disp(u)

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
I have a celll u(5,1) that looks like : u{​​​​​1,1}​​​​​=''ART1/TEACH'' u{​​​​​2,1}​​​​​=''H0ME/SHOW'' I want to remove the...
I have a celll u(5,1) that looks like : u{​​​​​1,1}​​​​​=''ART1/TEACH'' u{​​​​​2,1}​​​​​=''H0ME/SHOW'' I want to remove the first 5 characters from each of these strings so that in MATLAB: u{​​​​​1,1}​​​​​=''TEACH'' u{​​​​​2,1}​​​​​=''SHOW'' How can I do it?
In narrative essay format, I want you to address a business/organization case study using multiple concepts...
In narrative essay format, I want you to address a business/organization case study using multiple concepts from class. The case question and case text begin on page 5 of this document. You need to demonstrate their best understanding of management and organizational behavior theory, and the application of those ideas to improve the understanding of various issues. You need to clearly identify at least 3 distinct, substantive issues. For each issue you need to 1), identify evidence from the case...
It had been a busy day for Marsha Chamberland. She had spent most of it cleaning...
It had been a busy day for Marsha Chamberland. She had spent most of it cleaning and running errands in prepara- tion for her brother-in-law Ed’s return, and now she was preparing a quick dinner for her family. Ed, an industry official whose job it was to decide whether or not new products needed premarket approval by the U.S. Food and Drug Administration, had spent the last two weeks in Tennessee expressing his views on genetic engineering in food. He...
Please answer the following Case analysis questions 1-How is New Balance performing compared to its primary...
Please answer the following Case analysis questions 1-How is New Balance performing compared to its primary rivals? How will the acquisition of Reebok by Adidas impact the structure of the athletic shoe industry? Is this likely to be favorable or unfavorable for New Balance? 2- What issues does New Balance management need to address? 3-What recommendations would you make to New Balance Management? What does New Balance need to do to continue to be successful? Should management continue to invest...