plot a graph with 3 variables.
119 次查看(过去 30 天)
显示 更早的评论
I have this data on excel:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/156175/image.jpeg)
first column is temperature, and first row is voltage, the other data are seconds. How could I plot this table on matlab??? Because I only did plots with two variables and in this case i dont know.
Thanks for your attention.
采纳的回答
Ilham Hardy
2014-2-5
It depends on which plot type do you want,
e.g.
mesh(x,y,z)
surf(x,y,z)
2 个评论
Ilham Hardy
2014-2-5
Say the matrix is located in Excel file test.xlsx at field A1:H9
First, import value
impval = xlsread('test.xlsx','a1:h9');
since the matrix(1,1) {1st column, 1st row} is empty in the excel file matlab will put NaN during the data import see below
>> impval =
NaN 0.6000 0.6250 0.6500 0.6750 0.7000 0.7250 0.7500
25.0000 301.0000 310.0000 319.0000 328.0000 337.0000 346.0000 355.0000
45.0000 302.0000 312.0000 322.0000 332.0000 342.0000 352.0000 362.0000
65.0000 303.0000 314.0000 325.0000 336.0000 347.0000 358.0000 369.0000
85.0000 304.0000 316.0000 328.0000 340.0000 352.0000 364.0000 376.0000
105.0000 305.0000 318.0000 331.0000 344.0000 357.0000 370.0000 383.0000
125.0000 306.0000 320.0000 334.0000 348.0000 362.0000 376.0000 390.0000
145.0000 307.0000 322.0000 337.0000 352.0000 367.0000 382.0000 397.0000
165.0000 308.0000 324.0000 340.0000 356.0000 372.0000 388.0000 404.0000
divide the matrix into three seperate groups
time data
t_data = impval(2:end,1);
>> t_data =
25
45
65
85
105
125
145
165
voltage data
v_data = impval(1,2:end);
>> v_data =
0.6000 0.6250 0.6500 0.6750 0.7000 0.7250 0.7500
matrix data
m_data = impval(2:end,2:end);
>> m_data =
301 310 319 328 337 346 355
302 312 322 332 342 352 362
303 314 325 336 347 358 369
304 316 328 340 352 364 376
305 318 331 344 357 370 383
306 320 334 348 362 376 390
307 322 337 352 367 382 397
308 324 340 356 372 388 404
plot the data accordingly
figure(1)
mesh(v_data,t_data,m_data);
figure(2)
surf(v_data,t_data,m_data);
更多回答(1 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Line Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!