How can I build a Matrix dependencies of a variabel and a matrix? Easy question..
Show older comments
*Here is an example,
N3 uses N2 and one "k" variable(k is 3 for N3). But I entered k variable by hand. Since I want to find N4 using N3 and "k" (k is 4 for N4), I want "k" goes automaticly...
k starts from 2 and ends whenever I want. I don't want to create another for loop because I have already 2 for loops.And I know there is an easy way.But I couldn't remember it. Something like= N3(:,:,3).*What we_ call *_for these matrices? If you don't know how to this way, can you tell me how to do with for loops?
Thanks and Best Regards..
------------------
N2=zeros(rr-3,rr-2);
for j=1:rr-3
for i=1:rr-2
A1=(X(i+1)-X(i));
A2=(X(i+2)-X(i+1));
if A1==0 && A2==0
N2(j,i)=0;
elseif A1==0 && A2~=0
N2(j,i)=((X(i+2)-t(j))/(A2))*N1(j,i+1);
elseif A2==0 && A1~=0
N2(j,i)=((t(j)-X(i))/(A1))*N1(j,i);
elseif A2~=0 && A1~=0
N2(j,i)=((X(i+2)-t(j))/(A2))*N1(j,i+1)+((t(j)-X(i))/(A1))*N1(j,i);
end
end
------------------------
N3=zeros(rr-3,rr-3);
for j=1:rr-3
for i=1:rr-3
A1=(X(i+2)-X(i));
A2=(X(i+3)-X(i+1));
if A1==0 && A2==0
N3(j,i)=0;
elseif A1==0 && A2~=0
N3(j,i)=((X(i+3)-t(j))/(A2))*N2(j,i+1);
elseif A2==0 && A1~=0
N3(j,i)=((t(j)-X(i))/(A1))*N2(j,i);
elseif A2~=0 && A1~=0
N3(j,i)=((t(j)-X(i))/(A1))*N2(j,i)+((X(i+3)-t(j))/(A2))*N2(j,i+1);
end
end
end
------------------------
Accepted Answer
More Answers (1)
7 Comments
Jan
on 17 Jul 2013
Give me a chance to run this function by providing test data for N{1}, rr, t and X. Perhaps simple RAND data are sufficient, but most likely something more tricky is required to ensure that some A1 and A2 are zero.
STamer
on 17 Jul 2013
Jan
on 17 Jul 2013
[Ignore this] This is my magic FLAGFLAGFLAG because the forum does not allow to set a bookmark.
STamer
on 17 Jul 2013
Cedric
on 17 Jul 2013
[Ignore this] This is my magic FLAGFLAGFLAG because the forum does not allow to set a bookmark.
:-)
C
@STamer: I added a personal flag such that I can let Google find it again, when I'm back on my Matlab computer. I see so many messages per day, that I cannot remember where I wanted to add something after a test with Matlab. Sorry for the confusion.
Actually I do not like to sync my bookmarks through the internet. But of course I could sync a list of my visited links by Prism.
Unfortunately I'm too tired now for further experiments. I take a look into the problem tomorrow, if no other contributor has been faster.
STamer
on 18 Jul 2013
Categories
Find more on Language Fundamentals 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!