I am using MATLAB coder to generate code for following function.
function [D] = getInterpolatedTransforms(q0,t0,q1,t1,steps,correction) D = zeros(4,4,steps); for i = 0:1:steps-1 coeff = single(i/steps); qt = slerp(q0,q1,coeff); tt = [t0*(1-coeff)+t1*coeff,1]'; D(1:3,1:3,i+1) = (quat2rotm(qt))*correction; D(1:4,4,i+1) = tt; end end
I get following error while generating code at the "check for issues" step>
??? This assignment writes a 'single' value into a 'double' type. Code generation does not support changing types through assignment. Check preceding assignments or input type specifications for type mismatches. Error in ==>> quaternioncg Line: 48 Column: 17 Code generation failed: View Error Report ??? This assignment writes a 'single' value into a 'double' type. Code generation does not support changing types through assignment. Check preceding assignments or input type specifications for type mismatches. Error in ==>> quaternioncg Line: 48 Column: 17 Code generation failed: View Error Report
The location of the error is in Matlab internal file quaternioncg.m
Solution 1 : Remove the single cast
function [D] = getInterpolatedTransforms(q0,t0,q1,t1,steps,correction) D = zeros(4,4,steps); for i = 0:1:steps-1 coeff = i/steps; qt = slerp(q0,q1,coeff); tt = [t0*(1-coeff)+t1*coeff,1]'; D(1:3,1:3,i+1) = (quat2rotm(qt))*correction; D(1:4,4,i+1) = tt; end end
Solution 2: Make the input quaternion as single
>> a = quaternion(single([45,0,0]),'eulerd','ZYX','frame'); >> c = quaternion(single([-45,0,0]),'eulerd','ZYX','frame'); >> codegen getInterpolatedTransforms -args {a,1:3,c,3:5,10,0.5} -report
Matlabsolutions.com provides guaranteed satisfaction with a
commitment to complete the work within time. Combined with our meticulous work ethics and extensive domain
experience, We are the ideal partner for all your homework/assignment needs. We pledge to provide 24*7 support
to dissolve all your academic doubts. We are composed of 300+ esteemed Matlab and other experts who have been
empanelled after extensive research and quality check.
Matlabsolutions.com provides undivided attention to each Matlab
assignment order with a methodical approach to solution. Our network span is not restricted to US, UK and Australia rather extends to countries like Singapore, Canada and UAE. Our Matlab assignment help services
include Image Processing Assignments, Electrical Engineering Assignments, Matlab homework help, Matlab Research Paper help, Matlab Simulink help. Get your work
done at the best price in industry.