I have a 84x4 table with columns class, p, h and time. I am trying to extract data one by one and plot using bubblechart so that it displays continuous like a movie. The code looks like the following given. But it does not work. Please suggest/help me.
for k=1:84
class1=class(k);
p=p(k);
h=h(k);
d1=time(k);
bubblechart(d1,h1,p1)
hold on
grid on
title(['p vs h at time = ',num2str(d1), 'days'])
pause(1)
end

 채택된 답변

Walter Roberson
Walter Roberson 2021년 7월 19일

0 개 추천

%let T be the table
for k = 1 : height(T)
bubblechart(T.time(1:k), T.h(1:k), T.p(1:k));
grid on
title("p vs h at time = " + string(T.time(k)) + " days")
pause(1)
end

댓글 수: 3

Thank you so much for replying. In my table (84x4), the 1st column is name categorized as class, 2nd column is time, 3rd and 4th column are values for variables p and h respectively. I have taken your code in here. I seem to get an error after the end of for-loop stating the following:
Error using tabular/dotParenReference (line xx)
Unrecognized table variable name 'time'.
I'll post my complete code. Perhaps I'm doing something wrong.
Also, I need to clarify the column class. It has names a1, 14 times, then b1 (14 times), c1 (14 times) and d1 (14 times). Can I parallely display bubble plot for a1, b1 c1 and d1 running parallel/together from 1 to 14?
All your help is much appreciated.
T=readtable('p_vs_h test.xlsx')
class=T(:,1);
time=T(:,2);
p=T(:,3);
h=T(:,4);
for k = 1 : height(T)
bubblechart(T.time(1:k), T.h(1:k), T.p(1:k));
grid on
title("p vs h at time = " + string(T.time(k)) + " days")
pause(1)
end
Maybe something like
T = readtable('p_vs_h test.xlsx')
class = T{:,1};
time = T{:,2};
p = T{:,3};
h = T{:,4};
for k = 1 : 14
bubblechart(time(k:14:end), h(k:14:end), p(k:14:end));
grid on
title("p vs h at time = " + string(time(k)) + " days")
pause(1)
end
Yes, that is a lot helpful! Thank you. There are some minor issues remaining that I will try to solve. But your help was great!

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Creating, Deleting, and Querying Graphics Objects에 대해 자세히 알아보기

질문:

2021년 7월 19일

댓글:

2021년 7월 20일

Community Treasure Hunt

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

Start Hunting!

Translated by