it says it cant plot because my vectors aren't the same size but they are
2 views (last 30 days)
Show older comments
yvec=[6.67 17.33 42.67 37.33 30.10 29.31 28.74];
xvec=[0 6 10 13 17 20 28];
xvar=0:.001:28;
yvar=P_N(xvec,yvec,xvar);
plot(xvar,yvar,xvec,yvec,'r*')
trying to run this code but it says
Error using plot
Vectors must be the same length. anyone know how to fix this?
0 Comments
Answers (1)
Torsten
on 19 Mar 2023
Check whether size(yvar) equals size(xvar).
I think this cannot be true because the following code works:
yvec=[6.67 17.33 42.67 37.33 30.10 29.31 28.74];
xvec=[0 6 10 13 17 20 28];
xvar=0:.001:28;
%yvar=P_N(xvec,yvec,xvar);
yvar = rand(size(xvar));
plot(xvar,yvar,xvec,yvec,'r*')
3 Comments
Torsten
on 19 Mar 2023
You call P_N as
yvar=P_N(xvec,yvec,xvar);
and the function is given as
function [out] = P_N(xvar,xvec,yvec)
Do you see that the inputs in the call to P_N are in the wrong order ?
See Also
Categories
Find more on Spreadsheets in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!