Plotting data excel into matlab

1 次查看(过去 30 天)
I have two column in excel I want to plot them by using matlab, lets say I have first column from B2-B702 and second column from C2-C702. Column B is a number (age) while column C is string (tamoxifen / none treatment). I want to plot the age range data based on tamoxifen treatment or not and see the amount of patient based on the age range. How could I plot them in MATLAB ?? please help..

采纳的回答

Guru
Guru 2013-7-4
Read in the data into matlab using xlsread, then plot them once they are read into the MATLAB workspace
doc xlsread
doc plot
  5 个评论
Guru
Guru 2013-7-5
Either one, generally people don't like to change the raw data itself, excel in this case. So something along the lines of
y = strrep(y,'YES','1')
y = strrep(y,'NO','0')
y = str2double(y)
This would convert all instances of NO to 0, and all instance of YES to 1 so you can then plot it
izyan izzati
izyan izzati 2013-7-10
hye thank you for the example. I've tried to replace the string with number. It works but in command window only. When I checked at the workspace and click at TAM_TREATMENT it still show NaN. How I want it convert the num directly into my excel file? I'm sorry since this is my first time using matlab. All of it seem new to me. This is what I've typed
A = xlsread ('Data.xlsx')
[A, headertext] = xlsread ('Data.xlsx')
y = headertext(TAM_TREATMENT)
y = headertext(1:end, 12)
y = strrep (y, 'YES', '1')
y= strrep (y, 'NO', '0')
y = str2double(y)
x=AGE
plot (x,y)
??? Error using ==> plot
Vectors must be the same lengths.

请先登录,再进行评论。

更多回答(0 个)

类别

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