Number of elements mismatch.
Hi everyone,
I have a dimension issue:
I have a Simulink Matlab Function block that has a [3x1] vector of values called pd as its input. This vector should turn into a [6x1] vector called pdot by adding three zeros to every element. Basically just resizing
from
to
it sounds rather simple but I can’t get it to work. The code that I use in my Simulink function block is shown below.
function pdot = fcn(pd)
pdot = zeros(6,1);
temp = zeros(6,1);
for i = 1:length(pd)
pdot(i) = temp(i) + [pd(i); 0; 0; 0];
end
end
NOTE:-
Matlabsolutions.com provide latest MatLab Homework Help,MatLab Assignment Help for students, engineers and researchers in Multiple Branches like ECE, EEE, CSE, Mechanical, Civil with 100% output.Matlab Code for B.E, B.Tech,M.E,M.Tech, Ph.D. Scholars with 100% privacy guaranteed. Get MATLAB projects with source code for your learning and research.
Expert Answer
Neeta Dsouza answered . 2021–10–20 09:41:10
This seems like you maybe over complicated it? Is it as simple as…
x=[1;3;5]
x = 3×1
1 3 5
fcn(x)
ans = 6×1
1 3 5 0 0 0
function pdot = fcn(pd)
pdot=[pd;0;0;0];
end