finding 2D curvature for a left ventricular plot

> load('D:\Matlab\315 Big.txt');
Vertices=[sin(r) cos(r)]*10;
Lines=[(1:size(Vertices,1))' (2:size(Vertices,1)+1)']; Lines(end,2)=1;
Na=zeros(size(Vertices,1),1); Nb=zeros(size(Vertices,1),1);
Na(Lines(:,1))=Lines(:,2); Nb(Lines(:,2))=Lines(:,1);
checkNa=Na==0;
checkNb=Nb==0;
Naa=Na;
Nbb=Nb;
Naa(checkNa)=find(checkNa);
Nbb(checkNb)=find(checkNb);
Na(checkNa)=Nbb(Nbb(checkNa));
Nb(checkNb)=Naa(Naa(checkNb));
Ta=-sqrt(sum((Vertices-Vertices(Na,:)).^2,2));
Tb=sqrt(sum((Vertices-Vertices(Nb,:)).^2,2));
Ta(checkNa)=-Ta(checkNa);
Tb(checkNb)=-Tb(checkNb);
x = [Vertices(Na,1) Vertices(:,1) Vertices(Nb,1)];
y = [Vertices(Na,2) Vertices(:,2) Vertices(Nb,2)];
M = [ones(size(Tb)) -Ta Ta.^2 ones(size(Tb)) zeros(size(Tb)) zeros(size(Tb)) ones(size(Tb)) -Tb Tb.^2];
invM=M.^-1;
a(:,1)=invM(:,1,1).*x(:,1)+invM(:,2,1).*x(:,2)+invM(:,3,1).*x(:,3);
a(:,2)=invM(:,1,2).*x(:,1)+invM(:,2,2).*x(:,2)+invM(:,3,2).*x(:,3);
_Index in position 3 exceeds array bounds (must not exceed 1)._

7 件のコメント

phuah yun
phuah yun 2018 年 11 月 1 日
im trying to get the curvature but i have no idea which codes to use.. rather challenging task when i have no basics of matlab at all
madhan ravi
madhan ravi 2018 年 11 月 1 日
編集済み: madhan ravi 2018 年 11 月 1 日
select the whole code and press the code button {} so that its easy to read and upload Big.txt file to test
phuah yun
phuah yun 2018 年 11 月 1 日
a(:,2)=invM(:,1,2).*x(:,1)+invM(:,2,2).*x(:,2)+invM(:,3,2).*x(:,3);
at this part it prompts (Index in position 3 exceeds array bounds (must not exceed 1).) is there any problem with this line?
madhan ravi
madhan ravi 2018 年 11 月 1 日
did you read my previous comment??
phuah yun
phuah yun 2018 年 11 月 1 日
yes, i have no idea how to do that..
Image Analyst
Image Analyst 2018 年 11 月 1 日
Edit your question, the click the paper click icon above the edit box.
madhan ravi
madhan ravi 2018 年 11 月 2 日
don't close question which has answers

サインインしてコメントする。

回答 (3 件)

KSSV
KSSV 2018 年 11 月 1 日

0 投票

1 件のコメント

KSSV
KSSV 2018 年 11 月 1 日
Vertices =load(''D:\Matlab\315 Big.txt');
Vertices(:,1) = [] ; % because all zeros
k=LineCurvature2D(Vertices) ;
Use the attached code as it is.....
Note that this is a function written by other guy. You need to rate it at the respective link.

サインインしてコメントする。

madhan ravi
madhan ravi 2018 年 11 月 1 日
編集済み: madhan ravi 2018 年 11 月 1 日

0 投票

M =load('D:\Matlab\315 Big.txt');
r=4;
Vertices=[sin(r) cos(r)]*10;
Lines=[(1:size(Vertices,1))' (2:size(Vertices,1)+1)']; Lines(end,2)=1;
Na=zeros(size(Vertices,1),1); Nb=zeros(size(Vertices,1),1);
Na(Lines(:,1))=Lines(:,2); Nb(Lines(:,2))=Lines(:,1);
checkNa=Na==0;
checkNb=Nb==0;
Naa=Na;
Nbb=Nb;
Naa(checkNa)=find(checkNa);
Nbb(checkNb)=find(checkNb);
Na(checkNa)=Nbb(Nbb(checkNa));
Nb(checkNb)=Naa(Naa(checkNb));
Ta=-sqrt(sum((Vertices-Vertices(Na,:)).^2,2));
Tb=sqrt(sum((Vertices-Vertices(Nb,:)).^2,2));
Ta(checkNa)=-Ta(checkNa);
Tb(checkNb)=-Tb(checkNb);
x = [Vertices(Na,1) Vertices(:,1) Vertices(Nb,1)];
y = [Vertices(Na,2) Vertices(:,2) Vertices(Nb,2)];
M = [ones(size(Tb)) -Ta Ta.^2 ones(size(Tb)) zeros(size(Tb)) zeros(size(Tb)) ones(size(Tb)) -Tb Tb.^2];
invM=M.^-1;
a(:,1)=invM.*x(1)+invM.*x(2)+invM.*x(3);

9 件のコメント

madhan ravi
madhan ravi 2018 年 11 月 1 日
if it doesn't work upload your text file by clicking the paperclip button
phuah yun
phuah yun 2018 年 11 月 1 日
This is the txt file. thanks so much
madhan ravi
madhan ravi 2018 年 11 月 1 日
check edited answer
phuah yun
phuah yun 2018 年 11 月 1 日
it says that the matrix size is different on the left and right. The code used was from the link KSSV provided just now same link but stuck.
KSSV
KSSV 2018 年 11 月 1 日
What made you to change the function? You can straight away use the function eh.
phuah yun
phuah yun 2018 年 11 月 1 日
the inverse M had an error code saying its undefined following by:a(:,2)=invM(:,1,2).*x(:,1)+invM(:,2,2).*x(:,2)+invM(:,3,2).*x(:,3); this having a error code: Index in position 3 exceeds array bounds (must not exceed 1).
KSSV
KSSV 2018 年 11 月 1 日
Clearly int he function invM is a 3D matrix..where as in your case it is not.....so the error. My question is what is stopping you to use the function with out changes? Why did you change it?
phuah yun
phuah yun 2018 年 11 月 1 日
i changed the function cos there is an error code.
KSSV
KSSV 2018 年 11 月 1 日
That case..you have to show us what error you got.

サインインしてコメントする。

Bruno Luong
Bruno Luong 2018 年 11 月 1 日

0 投票

The original code is here:
Sorry but you you don't master the MATH behind, why wasting your time (and our time) to make your horrible modifications?
The way you compute the inverse the matrix tells clearly that you don't have a math background to make any modification.

8 件のコメント

phuah yun
phuah yun 2018 年 11 月 1 日
yes i know nothing about this. trying to figure out. i used the original code, and got this error: function k=LineCurvature2D(Vertices,Lines) ↑ Error: Function definition not supported in this context. Create functions in code file.
Bruno Luong
Bruno Luong 2018 年 11 月 1 日
If you don't know how to download a FEX and how to use/call it then please ask question in this sense rather than trying to make modification on the code (again it beyond what your level of MATLAB) and ask why it doesn't work.
phuah yun
phuah yun 2018 年 11 月 1 日
would you be able to provide any assisstance in this case where the error code show: function k=LineCurvature2D(Vertices,Lines) ↑ Error: Function definition not supported in this context. Create functions in code file.
Bruno Luong
Bruno Luong 2018 年 11 月 1 日
Easy, just do what the message tells you "Create functions in code file."
Or you downnload the FEX zip file and unzip it in the working folder, and call it correctly, and not copy past the code in your script.
phuah yun
phuah yun 2018 年 11 月 1 日
how do i create functions in code file in this case? the function that i am supposed to code is this? (k=LineCurvature2D(Vertices,Lines))
Bruno Luong
Bruno Luong 2018 年 11 月 1 日
I just told you Downnload the FEX zip file and unzip it in the working folder
phuah yun
phuah yun 2018 年 11 月 1 日
im sorry but where is the working folder? i downloaded it, and opened it opened in the editor window. i started with M =load('D:\Matlab\315 Big.txt'); then followed by the code is that okay?
Bruno Luong
Bruno Luong 2018 年 11 月 1 日
Sorry I don't have time to help you. Please post question in separate thread might be someone else is able to help you with basic function calling or read the Matlab Starting Guide.

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeLarge Files and Big Data についてさらに検索

質問済み:

2018 年 11 月 1 日

再開済み:

2018 年 11 月 2 日

Community Treasure Hunt

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

Start Hunting!

Translated by