You are now following this question
- You will see updates in your followed content feed.
- You may receive emails, depending on your communication preferences.
input file - reading file
3 views (last 30 days)
Show older comments
Greetings,
I am working on an input file that should read my txt file (test.txt) and I was testing it to see if it reads it, but it does not read the .txt file. I am getting an error when I run it, I was wondering if you guys have an ideas as to why is giving me an error. Or do you guys have another approach that I could use instead of the txt file
any help would be greatly appreciated it
%%%DATA FOR MY INPUT FILE
10 10 1 %Sref bref cref
2 %patches
50 %nlattice for Patch 1
5 -5 0 1 -2 0 %x y z chord alphaol twist
0 0 0 1 -2 0 %x y z chord alphaol twist
50 %nlattice for Patch 1
0 0 0 1 -2 0 %x y z chord alphaol twist
0 0 0 1 -2 0 %x y z chord alphaol twist
0 1 10 %alpha_start alpha_step alpha_end
Accepted Answer
Mathieu NOE
on 5 Nov 2020
hello Eddy
a few minor buggs - corrected in you code
also no need to declare global variables - much more reliable to pass argument in functions
otherwise there was also a bug in your text file : the declared %Number of sections nlattice was not consistent with the actual number of lines below with data. There are only 2 lines of data while your declared 6 :
6 %Number of sections nlattice for Patch 1
5 -5 0 1 -2 0 % x y z chord alpha_0l twist %
0 0 0 1 -2 0
50 %lattice P2
6 %Number of sections nlattice for Patch 2
0 0 0 1 -2 0 % x y z chord alpha_0l twist %
5 5 0 1 -2 0
so changing the txt files + the minor bugs corrections = a solution that works !
hope it helped !
all the best , Mathieu
16 Comments
Eddy Ramirez
on 7 Nov 2020
Matthieu,
Thank you for the assistance, I saw the error a few after posting it and forgot to update this. I was wondering if you know the reason why I get 100x100 for DATA.n on the attached coding, I am trying to just do the math for my y-coordinates (2 column of DATA.s and DATA.e)
Mathieu NOE
on 8 Nov 2020
hello Eddy
in the subfunction "exex2w.m" there are 3 lines that does not to be inside the for loop as they have any relation with the i index of the for loop
DATA.m=.5*(DATA.s+DATA.e);
DATA.c=DATA.m(:,1)+(DATA.cref/2)+DATA.m(:,2)+DATA.m(:,3);
DATA.n=(DATA.s(:,2)-DATA.e(:,2))./(DATA.s(:,2)-DATA.e(:,2));
in the 3rd line (for DATA.n) , I suspect you don't get the right dimensions because of the missing "dot" for the division ;
now , I am surprised that you have exactly the same expression on the numerator and on the denominator , so DATA.n= 1 always; please check that , is there any error in the index of the DATA used to compute DATA.n
Complete function after some minor corrections - :
function DATA=exec2w(input_files1)
% global DATA
DATA=inputs_f1(input_files1);
DATA.nlatall=DATA.nlatticeP1+DATA.nlatticeP2;
DATA.alpha_step_final=DATA.alpha_start:DATA.alpha_step:DATA.alpha_end;
for i=1:DATA.nlatall/2
DATA.s(i,1)=DATA.x(1)+(DATA.x(2)-DATA.x(1))/(DATA.nlatall/2)*(i-1);
DATA.s(i,2)=DATA.y(1)+(DATA.y(2)-DATA.y(1))/(DATA.nlatall/2)*(i-1);
DATA.s(i,3)=DATA.z(1)+(DATA.z(2)-DATA.z(1))/(DATA.nlatall/2)*(i-1);
DATA.e(i,1)=DATA.x(1)+(DATA.x(2)-DATA.x(1))/(DATA.nlatall/2)*(i);
DATA.e(i,2)=DATA.y(1)+(DATA.y(2)-DATA.y(1))/(DATA.nlatall/2)*(i);
DATA.e(i,3)=DATA.z(1)+(DATA.z(2)-DATA.z(1))/(DATA.nlatall/2)*(i);
% DATA.m=.5*(DATA.s+DATA.e);
% DATA.c=DATA.m(:,1)+(DATA.cref/2)+DATA.m(:,2)+DATA.m(:,3);
% DATA.n=(DATA.s(:,2)-DATA.e(:,2))/(DATA.s(:,2)-DATA.e(:,2));
end
for i=DATA.nlatall/2:DATA.nlatall
DATA.s(i,1)=DATA.x1(1)+(DATA.x1(2)-DATA.x1(1))/(DATA.nlatall/2)*(i-DATA.nlatall/2+1);
DATA.s(i,2)=DATA.y1(1)+(DATA.y1(2)-DATA.y1(1))/(DATA.nlatall/2)*(i-DATA.nlatall/2+1);
DATA.s(i,3)=DATA.z1(1)+(DATA.z1(2)-DATA.z1(1))/(DATA.nlatall/2)*(i-DATA.nlatall/2+1);
DATA.e(i,1)=DATA.x1(1)+(DATA.x1(2)-DATA.x1(1))/(DATA.nlatall/2)*(i-DATA.nlatall/2);
DATA.e(i,2)=DATA.y1(1)+(DATA.y1(2)-DATA.y1(1))/(DATA.nlatall/2)*(i-DATA.nlatall/2);
DATA.e(i,3)=DATA.z1(1)+(DATA.z1(2)-DATA.z1(1))/(DATA.nlatall/2)*(i-DATA.nlatall/2);
% DATA.m=.5*(DATA.s+DATA.e);
% DATA.c=DATA.m(:,1)+(DATA.cref/2)+DATA.m(:,2)+DATA.m(:,3);
% DATA.n=(DATA.s(:,2)-DATA.e(:,2))/(DATA.s(:,2)-DATA.e(:,2));
end
DATA.m=.5*(DATA.s+DATA.e);
DATA.c=DATA.m(:,1)+(DATA.cref/2)+DATA.m(:,2)+DATA.m(:,3);
DATA.n=(DATA.s(:,2)-DATA.e(:,2))./(DATA.s(:,2)-DATA.e(:,2));% this equals 1 always ??
end
Eddy Ramirez
on 8 Nov 2020
Mathieu,
I cant believe a small dot can throw the whole thing off!! yes, that is the value and setup i was looking for it will always be 1!!! THANK YOU SO MUCH !!!
Mathieu NOE
on 9 Nov 2020
you're welcome
have a great day
Eddy Ramirez
on 12 Nov 2020
Mathieu,
I apologize for reaching out again, I was going to create a new forum, but decided to kindly request your assistance before. When I added the code below to the first loop, I was expecting to get 1 column with 3 rows (-2) values. But when I run it, it gives me 2 columns with 6 rows of -2 instead of just 1 column with 3 rows of (-2). I tried to changed it from (i,:) to (:,:), (1,:) and none of them are working out for me.
any assistance would be greatly appreciated and agian I apologize for reaching out
%%% i went ahead and added the twist as follow under the first for loop
DATA.test(i,:)=DATA.alpha_0l;
Mathieu NOE
on 12 Nov 2020
hello
not sure what yoour problem is really
also please clarify because you speak of adding "twist" and your code is about "alpha_0l"
I assume the new line of code goes into exec2w.m
so I put your code and basically, if we write DATA.test(i,:)=DATA.alpha_0l; , DATA.test will have the same amount of columns as DATA.alpha_0l and the number of columns of DATA.alpha_0l is given by the number of data lines you process
so what is the issue ?
see my test code and data (dummy 6 lines file)
Eddy Ramirez
on 13 Nov 2020
Yes, my apologies for the confusion, this is a new line I am drafting up for alpha_0l (I am adding the coding that I am currently working on and for this code I am running 6 lattices instead of 50 as the original coding.
The issue I am having is that I get two columns with 3 rows for DATA.alpha_0l. Now after reading your explanation, it makes sense as to why it provides the following
-2 -2
-2 -2
-2 -2
My intent is to only get 1 column with 3 rows of -2 for DATA.alpha_0l since I only have 3 lattices under patch1, but I think that might have to be a for loop correct? and 1 column with 6 rows when I do DATA.alpha_0l and DATA.alpha_0l1 (because each patch contains 3 lattices)
similar like this
-2
-2
-2
-2
-2
-2
I apologize for the confusion and I truly appreciate your feedback
Mathieu NOE
on 13 Nov 2020
hello
so slight modification in the exec2w file
DATA.test(2*i-1:2*i,:)=DATA.alpha_0l(:); % added (:) to create vertical vector in every case
this way you get the desired 6x1 output for DATA.test
I have not modified anything else
modified code below :
function DATA=exec2w(input_files1)
global DATA
DATA=inputs_f1(input_files1);
DATA.nlatall=DATA.nlatticeP1+DATA.nlatticeP2;
for i=1:DATA.nlatall/2
DATA.s(i,1)=DATA.x(1)+(DATA.x(2)-DATA.x(1))/(DATA.nlatall/2)*(i-1);
DATA.s(i,2)=DATA.y(1)+(DATA.y(2)-DATA.y(1))/(DATA.nlatall/2)*(i-1);
DATA.s(i,3)=DATA.z(1)+(DATA.z(2)-DATA.z(1))/(DATA.nlatall/2)*(i-1);
DATA.e(i,1)=DATA.x(1)+(DATA.x(2)-DATA.x(1))/(DATA.nlatall/2)*(i);
DATA.e(i,2)=DATA.y(1)+(DATA.y(2)-DATA.y(1))/(DATA.nlatall/2)*(i);
DATA.e(i,3)=DATA.z(1)+(DATA.z(2)-DATA.z(1))/(DATA.nlatall/2)*(i);
DATA.ltwist=DATA.twist(1)+(DATA.twist(2)-DATA.twist(1))/(DATA.nlatall/2)*(i-1);
% index for creating the vertical vector DATA.test
DATA.test(2*i-1:2*i,:)=DATA.alpha_0l(:); % added (:) to create vertical vector in every case
end
keyboard
for i=DATA.nlatall/2:DATA.nlatall
DATA.s(i,1)=DATA.x1(1)+(DATA.x1(2)-DATA.x1(1))/(DATA.nlatall/2)*(i-DATA.nlatall/2-1);
DATA.s(i,2)=DATA.y1(1)+(DATA.y1(2)-DATA.y1(1))/(DATA.nlatall/2)*(i-DATA.nlatall/2-1);
DATA.s(i,3)=DATA.z1(1)+(DATA.z1(2)-DATA.z1(1))/(DATA.nlatall/2)*(i-DATA.nlatall/2-1);
DATA.e(i,1)=DATA.x1(1)+(DATA.x1(2)-DATA.x1(1))/(DATA.nlatall/2)*(i-DATA.nlatall/2);
DATA.e(i,2)=DATA.y1(1)+(DATA.y1(2)-DATA.y1(1))/(DATA.nlatall/2)*(i-DATA.nlatall/2);
DATA.e(i,3)=DATA.z1(1)+(DATA.z1(2)-DATA.z1(1))/(DATA.nlatall/2)*(i-DATA.nlatall/2);
DATA.rtwist=DATA.twist1(1)+(DATA.twist1(2)-DATA.twist1(1))/(DATA.nlatall/2)*(i-DATA.nlatall/2);
end
DATA.final_twist=([DATA.ltwist;DATA.rtwist]);
DATA.m=(1/2.*(DATA.s+DATA.e));
DATA.c=[(DATA.m(:,1)+(DATA.cref/2)),DATA.m(:,(2:3))];
% DATA.dihedralangle=((DATA.e(i,3)-DATA.s(i,2))/DATA.e(i,2)-DATA.s(i,2));
DATA.t=[-1,0,0];
DATA.t1=[1,0,0];
DATA.nvector=DATA.e(i,:)-DATA.s(i,:);
DATA.nvectorcross=cross(DATA.nvector,DATA.t);
DATA.nfinal=DATA.nvectorcross./norm(DATA.nvectorcross);
% DATA.cpl=((DATA.chord-DATA.chord)/(2.*DATA.nlatall));
%%For-Loop for F & Fm Matrices%%
for irow=1:DATA.nlatall
for jcol=1:DATA.nlatall
DATA.bv_a=DATA.s(jcol,:)-DATA.c(irow,:);
DATA.bv_b=DATA.e(jcol,:)-DATA.c(irow,:);
DATA.bv_cross=cross(DATA.bv_a,DATA.bv_b);
DATA.bv_dot=dot(DATA.bv_a,DATA.bv_b);
DATA.bv_MagA=norm(DATA.bv_a);
DATA.bv_MagB=norm(DATA.bv_b);
DATA.qbv=(DATA.bv_cross./(dot(DATA.bv_cross,DATA.bv_cross))).*(DATA.bv_MagA+DATA.bv_MagB).*(1-((DATA.bv_dot)./(DATA.bv_MagA.*DATA.bv_MagB)));
DATA.qbv_term=dot(DATA.qbv,DATA.nfinal);
DATA.lhs_cross=cross(DATA.bv_a,DATA.t1);
DATA.lhs_dot=dot(DATA.lhs_cross,DATA.lhs_cross);
DATA.lhs_tdot=dot(DATA.bv_a,DATA.t1);
DATA.qlhs=(DATA.lhs_cross./(dot(DATA.lhs_cross,DATA.lhs_cross))).*(1-((DATA.lhs_tdot)./(DATA.bv_MagA)));
DATA.qlhs_term=dot(DATA.qlhs,DATA.nfinal);
DATA.rhs_cross=cross(DATA.bv_b,DATA.t1);
DATA.rhs_dot=dot(DATA.rhs_cross,DATA.rhs_cross);
DATA.rhs_tdot=dot(DATA.bv_b,DATA.t1);
DATA.qrhs=(DATA.rhs_cross./(dot(DATA.rhs_cross,DATA.rhs_cross))).*(1-((DATA.rhs_tdot)./(DATA.bv_MagB)));
DATA.qrhs_term=dot(DATA.qrhs,DATA.nfinal);
DATA.F=(1/(4*pi)).*(DATA.qbv_term-DATA.qlhs_term+DATA.qrhs_term);
DATA.F_Final(irow,jcol)=DATA.F;
DATA.bv_a1=DATA.s(jcol,:)-DATA.m(irow,:);
DATA.bv_b1=DATA.e(jcol,:)-DATA.m(irow,:);
DATA.bv_cross1=cross(DATA.bv_a1,DATA.bv_b1);
DATA.bv_dot1=dot(DATA.bv_a1,DATA.bv_b1);
DATA.bv_MagA1=norm(DATA.bv_a1);
DATA.bv_MagB1=norm(DATA.bv_b1);
DATA.qbv1=(DATA.bv_cross1./(dot(DATA.bv_cross1,DATA.bv_cross1))).*(DATA.bv_MagA1+DATA.bv_MagB1).*(1-((DATA.bv_dot1)./(DATA.bv_MagA1.*DATA.bv_MagB1)));
DATA.qbv_term1=dot(DATA.qbv1,DATA.nfinal);
DATA.lhs_cross1=cross(DATA.bv_a1,DATA.t1);
DATA.lhs_dot1=dot(DATA.lhs_cross1,DATA.lhs_cross1);
DATA.lhs_tdot1=dot(DATA.bv_a1,DATA.t1);
DATA.qlhs1=(DATA.lhs_cross1./(dot(DATA.lhs_cross1,DATA.lhs_cross1))).*(1-((DATA.lhs_tdot1)./(DATA.bv_MagA1)));
DATA.qlhs_term1=dot(DATA.qlhs1,-DATA.nfinal);
DATA.rhs_cross1=cross(DATA.bv_b1,DATA.t1);
DATA.rhs_dot1=dot(DATA.rhs_cross1,DATA.rhs_cross1);
DATA.rhs_tdot1=dot(DATA.bv_b1,DATA.t1);
DATA.qrhs1=(DATA.rhs_cross1./(dot(DATA.rhs_cross1,DATA.rhs_cross1))).*(1-((DATA.rhs_tdot1)./(DATA.bv_MagB1)));
DATA.qrhs_term1=dot(DATA.qrhs1,-DATA.nfinal);
DATA.Fm=(1/(4*pi)).*(DATA.qbv_term1-DATA.qlhs_term1+DATA.qrhs_term1);
DATA.Fm_Final(irow,jcol)=DATA.Fm;
end
end
%%ideas%%
for j=1:DATA.nlatall
for AOA_w=DATA.alpha_start:DATA.alpha_step:DATA.alpha_end
end
DATA.alpha_0l_final=(ones(j,1).*DATA.span_char(1,5));
keyboard
DATA.alpha_g=asind(sind(AOA_w)*cosd(DATA.theta));
DATA.alphag_final(j,:)=DATA.alpha_g;
DATA.Vn_Vinf_RHS=-(sin(DATA.alphag_final+DATA.final_twist-DATA.alpha_0l_final));
end
end
Eddy Ramirez
on 14 Nov 2020
so is it safe to assume that it will always provide a total of 6 values for each patch because of the data that I have (based on your explanation earlier)? I guess I misunderstood and I thought that I was supposed to get only 3 rows of 1 column for DATA.alpha_0l (patch 1) and 3 rows of 1 column for DATA.alpha_0l1 (patch2) giving the following for both patches (Patch1 and Patch 2)
-2
-2
-2
-2
-2
-2
Would I be able to run the same code for the other side? I tried to run it, for Patch2 but it is providng an error and I was trying to modify it, but not getting very lucky
%%PATCH 1 (3 lattices)
for i=1:DATA.nlatall/2
DATA.s(i,1)=DATA.x(1)+(DATA.x(2)-DATA.x(1))/(DATA.nlatall/2)*(i-1);
DATA.s(i,2)=DATA.y(1)+(DATA.y(2)-DATA.y(1))/(DATA.nlatall/2)*(i-1);
DATA.s(i,3)=DATA.z(1)+(DATA.z(2)-DATA.z(1))/(DATA.nlatall/2)*(i-1);
DATA.e(i,1)=DATA.x(1)+(DATA.x(2)-DATA.x(1))/(DATA.nlatall/2)*(i);
DATA.e(i,2)=DATA.y(1)+(DATA.y(2)-DATA.y(1))/(DATA.nlatall/2)*(i);
DATA.e(i,3)=DATA.z(1)+(DATA.z(2)-DATA.z(1))/(DATA.nlatall/2)*(i);
DATA.ltwist=DATA.twist(1)+(DATA.twist(2)-DATA.twist(1))/(DATA.nlatall/2)*(i-1);
% index for creating the vertical vector DATA.test
DATA.test(2*i-1:2*i,:)=DATA.alpha_0l(:); % added (:) to create vertical vector in every case
end
%%PATCH 2 (3 lattices)
for i=DATA.nlatall/2:DATA.nlatall
DATA.s(i,1)=DATA.x1(1)+(DATA.x1(2)-DATA.x1(1))/(DATA.nlatall/2)*(i-DATA.nlatall/2-1);
DATA.s(i,2)=DATA.y1(1)+(DATA.y1(2)-DATA.y1(1))/(DATA.nlatall/2)*(i-DATA.nlatall/2-1);
DATA.s(i,3)=DATA.z1(1)+(DATA.z1(2)-DATA.z1(1))/(DATA.nlatall/2)*(i-DATA.nlatall/2-1);
DATA.e(i,1)=DATA.x1(1)+(DATA.x1(2)-DATA.x1(1))/(DATA.nlatall/2)*(i-DATA.nlatall/2);
DATA.e(i,2)=DATA.y1(1)+(DATA.y1(2)-DATA.y1(1))/(DATA.nlatall/2)*(i-DATA.nlatall/2);
DATA.e(i,3)=DATA.z1(1)+(DATA.z1(2)-DATA.z1(1))/(DATA.nlatall/2)*(i-DATA.nlatall/2);
DATA.rtwist=DATA.twist1(1)+(DATA.twist1(2)-DATA.twist1(1))/(DATA.nlatall/2)*(i-DATA.nlatall/2);
DATA.test(2*i-1:2*i,:)=DATA.alpha_0l1(:);
end
Mathieu NOE
on 14 Nov 2020
hello
so let's start again from the beginning
your data file as for now is this :
10 % Sref
10 % bref
1 %cref
45 %lambda
0 %theta
2 %npatch
3 %nlattice P1
2 %Number of sections nlattice for Patch 1
5 -5 0 1 -2 0 % x y z chord alpha_0l twist %
0 0 0 1 -2 0
3 %nlattice P2
2 %Number of sections nlattice for Patch 2
0 0 0 1 -2 0 % x y z chord alpha_0l twist %
5 5 0 1 -2 0
0 %alpha_start
1 %alpha_step
5 %alpha_end
now please clarify how many -2 per patch are supposed to be stored if it's 3 or 6 and how the 3 or 6 qty is defined
my previous iteration was based for patch1 on the fact that you have 2 lines with -2 and that it was also specified : 3 %nlattice P1
so all in all I thought you wanted to have the 2 lines x 3 (from %nlattice P1 ) for patch 1
so what is the "true" amount of data ? per patch or both patches ? which lines am I supposed to grab for the -2 vales) ?
all the best
Eddy Ramirez
on 14 Nov 2020
Greetings,
I need 1 column of 3 rows for each patch
For Patch1 alpha_0l should be as follow
-2
-2
-2
For Patch2 alpha_0l should be as follow (in this case I will be using DATA.alpha_0l1 since that is how I am calling it for Patch 2, but they are the same value)
-2
-2
-2
Mathieu NOE
on 14 Nov 2020
hello
so just to be sure to understand : you want 3 lines of -2 for each patch , because of the "3" in :
3 %nlattice P1 (for patch 1) and same for patch 2
so for example for patch 1 , we repeat 3 times the -2 that appears in the line :
5 -5 0 1 -2 0 % x y z chord alpha_0l twist %
the next line is not to be considered ? I mean : 0 0 0 1 -2 0
Am I right ?
Eddy Ramirez
on 14 Nov 2020
that is correct, so the same for twist. I guess my initial drafts were inaccurate
For example, If I run the coding for Patch 1 with 3 lattices, we will repeat 3 times the -2 for alpha_0l and we will repeat 3 times the 0 for twist
so I am hoping to get something like this for Patch 1
alpha_0l
-2
-2
-2
twist
0
0
0
Eddy Ramirez
on 14 Nov 2020
Edited: Eddy Ramirez
on 14 Nov 2020
Mathieu,
I was able to work it, I did the following
DATA.nlatall=DATA.nlatticeP1+DATA.nlatticeP2;
for i=1:DATA.nlatall/2
DATA.s(i,1)=DATA.x(1)+(DATA.x(2)-DATA.x(1))/(DATA.nlatall/2)*(i-1);
DATA.s(i,2)=DATA.y(1)+(DATA.y(2)-DATA.y(1))/(DATA.nlatall/2)*(i-1);
DATA.s(i,3)=DATA.z(1)+(DATA.z(2)-DATA.z(1))/(DATA.nlatall/2)*(i-1);
DATA.e(i,1)=DATA.x(1)+(DATA.x(2)-DATA.x(1))/(DATA.nlatall/2)*(i);
DATA.e(i,2)=DATA.y(1)+(DATA.y(2)-DATA.y(1))/(DATA.nlatall/2)*(i);
DATA.e(i,3)=DATA.z(1)+(DATA.z(2)-DATA.z(1))/(DATA.nlatall/2)*(i);
DATA.F_alpha_0l(i,1)=DATA.alpha_0l(1)+(DATA.alpha_0l(2)-DATA.alpha_0l(1))/(DATA.nlatall/2)*(i);
DATA.F_twist(i,1)=DATA.twist(1)+(DATA.twist(2)-DATA.twist(1))/(DATA.nlatall/2)*(i);
end
for i=DATA.nlatall/2:DATA.nlatall
DATA.s(i,1)=DATA.x1(1)+(DATA.x1(2)-DATA.x1(1))/(DATA.nlatall/2)*(i-DATA.nlatall/2-1);
DATA.s(i,2)=DATA.y1(1)+(DATA.y1(2)-DATA.y1(1))/(DATA.nlatall/2)*(i-DATA.nlatall/2-1);
DATA.s(i,3)=DATA.z1(1)+(DATA.z1(2)-DATA.z1(1))/(DATA.nlatall/2)*(i-DATA.nlatall/2-1);
DATA.e(i,1)=DATA.x1(1)+(DATA.x1(2)-DATA.x1(1))/(DATA.nlatall/2)*(i-DATA.nlatall/2);
DATA.e(i,2)=DATA.y1(1)+(DATA.y1(2)-DATA.y1(1))/(DATA.nlatall/2)*(i-DATA.nlatall/2);
DATA.e(i,3)=DATA.z1(1)+(DATA.z1(2)-DATA.z1(1))/(DATA.nlatall/2)*(i-DATA.nlatall/2);
DATA.F_alpha_0l(i,1)=DATA.alpha_0l1(1)+(DATA.alpha_0l1(2)-DATA.alpha_0l1(1))/(DATA.nlatall/2)*(i-DATA.nlatall/2);
DATA.F_twist(i,1)=DATA.twist1(1)+(DATA.twist1(2)-DATA.twist1(1))/(DATA.nlatall/2)*(i-DATA.nlatall/2);
end
Eddy Ramirez
on 14 Nov 2020
do you know what the reason could be as to why my DATA.s is throwing a negative number on the third row for x?
5.0000 -5.0000 0
3.3333 -3.3333 0
-1.6667 -1.6667 0
0 0 0
1.6667 1.6667 0
3.3333 3.3333 0
Mathieu NOE
on 15 Nov 2020
hello Eddy
there is (for me) an issue with the stop index of the first for loop and the start index of the second for loop
they are both equal to DATA.nlatall/2 ( = 3) (and this shouldn't be the case normally)
at the end of the first forr loop (when i = 3) : DATA.s(i,1) = 1.6667
but then you start the second for loop again at same index i = DATA.nlatall/2 ( = 3)
so you overwrite the previous values ,
and with the new equation for DATA.s(i,1) we get a negative value : DATA.s(i,1) = -1.6667
so for me there is a problem with the index when your first for loop must stop and when your second loop must start; the index should not be the same
More Answers (0)
See Also
Categories
Find more on Annotations 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!An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom(English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)