MATLAB: Why am I receiving “Input data must be a numeric, cell, or logical array.” message when I used p= vpa(q)

cellerror "input data must be a numericor logical array."

D=[];
Q=[];
for d=3:0.1:5
m=(pi*((d)^2)*8.9)/4;
M=(m/465.96)*1000;
syms t
q=int (m*(103.60+0.034*t),300, 773);
p=vpa(q);
%q in joules
D=[D,d];
Q=[Q,p];
end
xlswrite('C:\sharad\asaas',D','B2:B4902')
xlswrite('C:\sharad\asaas',Q','C2:C4902')

Best Answer

I cannot reproduce that error. Your code runs fine for me (in R2016a).
When I add this line after the loop:
DQ = [D; Q]
I get:
DQ =
[ 3, 31/10, 16/5, 33/10, 17/5, 7/2, 18/5, 37/10, 19/5, 39/10, 4, 41/10, 21/5, 43/10, 22/5, 9/2, 23/5, 47/10, 24/5, 49/10, 5]
[ 3625575.8300848154758568853139877, 3871309.3030127863021334633231163, 4125099.6111187233836972154676914, 4386946.7544026267278240993618965, 4656850.7328644963272381573915482, 4934811.5465043321746634319424629, 5220829.1953221342846518382430077, 5514903.6793179032101761549711227, 5817034.9984916372632142156362534, 6127223.1528433372586732730269432, 6445468.142373005292029120028019, 6771769.9670806377980625256896019, 7106128.6269662383274408057332039, 7448544.1220298032130813226103783, 7799016.4522713363985531032085419, 8157545.6176908348279539495706558, 8524131.6182882994762621819972992, 8898774.4540637318859808146953583, 9281474.1250171276042237877845764, 9672230.6311484935285989195108414, 10071043.972457820782437920570374]