mat-lab function take two numbers return nxn matrix

a getCoords() function that prompts the user for the x- and y-coordinates for the two endpoints for the five line segments returns it as 5-by-4 matrix of points?

5 comentarios

Rik
Rik el 22 de Abr. de 2018

It is not clear what you mean. Write a more detailed description of your input, your desired output, and the code you have tried so far. Have a read here and here. It will greatly improve your chances of getting an answer.

Write a program that prompts the user for endpoints (x1, y1) and (x2, y2) of five (5) line segments, and calculates the midpoint of each line segment, which is the point (xm, ym).
tamara salah
tamara salah el 22 de Abr. de 2018
Editada: Walter Roberson el 22 de Abr. de 2018
function [mid] = findmid (pt1,pt2)
mid = 0.58*(pt1+pt2);
return  
end 
function [xpt,ypt] = getcroods (matrix)
n=5; % number of lines
a= inputdlg('enter x coordinates','test',n);
xpt=matrix(a{1});
b= inputdlg('enter y coordinates','test',n);
ypt=matrix(b{1});
return 
end
function [midx,midy] = midpoint(num)
x1 = num(getcroods (x));
x2 = num (getcroods (y));
x3= num(getcroods (c));
x4= num(getcroods (v));
x5 = num(getcroods (b));
y1= num(getcroods (n));
y2= num(getcroods (m));
y3=num(getcroods (k));
y4=num(getcroods (h));
y5 = num(getcroods (g));
midx = findmid (x1,x2,x3,x4,x5);
midy = findmid(y1,y2,y3,y4,y5);
return
end 
those are the function I wrote, but since i'm new, I can't get why it's not working :( and how do I call a function is not working either

What is num() ?

What are x, y, c, and so on, that you are passing to getcroods?

Note: inputdlg() returns a cell array of character vectors, so your

a= inputdlg('enter x coordinates','test',n);
xpt=matrix(a{1});

would be attempting to index matrix at a character vector. Indexing at a character vector is permitted and has good uses, but most of the time if you index by a character vector you have probably done something wrong.

Iniciar sesión para comentar.

Respuestas (0)

Preguntada:

el 22 de Abr. de 2018

Comentada:

el 22 de Abr. de 2018

Community Treasure Hunt

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

Start Hunting!

Translated by