Variable q10 must be of data type double. It is currently of type sym. Check where the variable is assigned a value.

3 views (last 30 days)
I was wondering what to do to chane my data type to double? I am very new to matlab and this is the only error that is coming up in my assignment
P = [3,2,-1];
Q = [5,0,1];
n = [4,7,-2];
syms x y z
f(x,y,z) = (4*(x-3)+7*(y-2)-2*(z+1));
q10 = abs((f(5,0,1))/(norm(n)))
q10 = 

Answers (1)

Steven Lord
Steven Lord on 6 Feb 2024
As you can see from the fact that your code ran in MATLAB Answers, your code does work. I'm assuming that you're running this in something like MATLAB Grader or MATLAB Onramp that checks certain qualities (chosen by the problem author) about the results.
In that case you're likely going to want to convert the symbolic answer into its numeric (double) representation.
P = [3,2,-1];
Q = [5,0,1];
n = [4,7,-2];
syms x y z
f(x,y,z) = (4*(x-3)+7*(y-2)-2*(z+1));
q10 = abs((f(5,0,1))/(norm(n)))
q10 = 
D = double(q10)
D = 1.2039
format longg
D
D =
1.20385853085769

Tags

Products

Community Treasure Hunt

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

Start Hunting!