why am I receiving "Input data must be a numeric, cell, or logical array." message when I used p= vpa(q) ?

6 views (last 30 days)
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')

Accepted Answer

Star Strider
Star Strider on 22 Jun 2016
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]
  2 Comments
sharad tiwari
sharad tiwari on 22 Jun 2016
Thanks for answering but I am still receiving error in line 19 here it says Error using xlswrite (line 166) Input data must be a numeric, cell, or logical array.
Error in heat_vs_diameter_unsuccessful (line 19) xlswrite('C:\sharad\asaas',Q','C2:C4902')
Although when I write what you suggested it worked with same error message. Any suggestion ?
Star Strider
Star Strider on 22 Jun 2016
My pleasure.
You didn’t mention that the problem was occurring in your xlswrite call. The ‘DQ’ in my code is a sym object. To convert it to a double array, use the double function:
DQ = double([D; Q])
That will work.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!