How to skip [] when add values to a vector variable?
Mostrar comentarios más antiguos
How to avoid having to put [] around the values that are going into the vector variable when using input command?
for i = 1:n;
values=input('Enter a value [x y]: ');
point=[point; values]
end
Enter a point [x y]: 2 2
Error using askpoints (line 7)
Error: Invalid expression. Check for missing multiplication operator, missing or
unbalanced delimiters, or other syntax error. To construct matrices, use brackets
instead of parentheses.
Respuestas (2)
madhan ravi
el 5 de Dic. de 2018
Editada: madhan ravi
el 5 de Dic. de 2018
% Just alter the below lines in your code
points=cell(1,n); % before loop
points{i}=values; %inside loop
cell2mat(points) %outside loop
5 comentarios
Fille
el 5 de Dic. de 2018
Fille
el 5 de Dic. de 2018
madhan ravi
el 5 de Dic. de 2018
give input as shown
[2 2]
reshape([points{:}],[],2) % change last line to this also remove i=i+1;
Fille
el 6 de Dic. de 2018
madhan ravi
el 6 de Dic. de 2018
values=input('Enter a point [x y]: ')*[ones(1,2)]
str = input('Enter values x y: ','s');
vec = sscanf(str,'%f')
Categorías
Más información sobre Operators and Elementary Operations en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!