Shaping a vector in a 2 dimensional array changes the value of its element

1 view (last 30 days)
hello, I have encountered a weird problem, and I have no idea were it's coming from nor how to fix it. I'm running a simulation that produces the value of some signal given the sweep of two degrees of freedom, and produces the following table of numbers:
8.954999999999999716e+01 8.229999999999999716e+01 1.912311942879310056e+00
8.954999999999999716e+01 8.256999999999999318e+01 1.912065367951790051e+00
8.954999999999999716e+01 8.283999999999998920e+01 1.911807135252229894e+00
8.954999999999999716e+01 8.310999999999998522e+01 1.911537066568889998e+00
8.954999999999999716e+01 8.337999999999998124e+01 1.911255040393869953e+00
8.954999999999999716e+01 8.364999999999997726e+01 1.910961001580250063e+00
8.970999999999999375e+01 8.229999999999999716e+01 1.190501119700960064e+00
8.970999999999999375e+01 8.256999999999999318e+01 1.190272541783059967e+00
8.970999999999999375e+01 8.283999999999998920e+01 1.190029635127519914e+00
8.970999999999999375e+01 8.310999999999998522e+01 1.189771942479229905e+00
8.970999999999999375e+01 8.337999999999998124e+01 1.189499049269389985e+00
8.970999999999999375e+01 8.364999999999997726e+01 1.189210594429920054e+00
8.986999999999999034e+01 8.229999999999999716e+01 1.839148205713659889e-01
8.986999999999999034e+01 8.256999999999999318e+01 1.837522991314629872e-01
8.986999999999999034e+01 8.283999999999998920e+01 1.835736054040819909e-01
8.986999999999999034e+01 8.310999999999998522e+01 1.833779314626949875e-01
8.986999999999999034e+01 8.337999999999998124e+01 1.831644854964790126e-01
8.986999999999999034e+01 8.364999999999997726e+01 1.829325028324620128e-01
9.002999999999998693e+01 8.229999999999999716e+01 -1.016653356584209966e+00
9.002999999999998693e+01 8.256999999999999318e+01 -1.016678337376800023e+00
9.002999999999998693e+01 8.283999999999998920e+01 -1.016718053172849912e+00
9.002999999999998693e+01 8.310999999999998522e+01 -1.016773616528650059e+00
9.002999999999998693e+01 8.337999999999998124e+01 -1.016846165599589957e+00
9.002999999999998693e+01 8.364999999999997726e+01 -1.016936855342200019e+00
9.018999999999998352e+01 8.229999999999999716e+01 -2.127515816405140203e+00
9.018999999999998352e+01 8.256999999999999318e+01 -2.127387035322549913e+00
9.018999999999998352e+01 8.283999999999998920e+01 -2.127267539418430164e+00
9.018999999999998352e+01 8.310999999999998522e+01 -2.127158479522750056e+00
9.018999999999998352e+01 8.337999999999998124e+01 -2.127061070826279821e+00
9.018999999999998352e+01 8.364999999999997726e+01 -2.126976588750999930e+00
the first and second column are X and Y: X changes its value when Y has completed its sweep, which is then repeated for the next value of X and so on. The third column gives the value of the signal that I am actually interested in. I am using the following code to reshape it in a 6x5 matrix:
function [x,y,M]=convert3D(X,Y,Z)
[row,col]=size(Z);
nxp=length(find (Y(:)==Y(1)));
nyp=row/nxp;
y=Y(1:nyp);
x=X(1:nyp:row);
M=zeros(nyp,nxp,col);
for i=1:col
M(:,:,i)=reshape(Z(:,i),nyp,nxp);
end
myDir = uigetdir; %gets directory
%%
myFiles = (dir(fullfile(myDir,'*.txt'))); %gets all .txt files in myDir
mySortedFiles = natsortfiles({myFiles.name}); %sort all files naturally in a tab
mySortedStruct = cell2struct(mySortedFiles,'name',length(myFiles)); %turn the sorted tab in a struct
for k = 1:MICH_sweep_idx
DataMatrix = load(mySortedStruct(k).name);
[x,y,PRCL_err] = convert3D(DataMatrix(:,1), DataMatrix(:,2), DataMatrix(:,3));
PRCL_err_cube(:,:,k) = PRCL_err;
end
The file that I showed is part of a collection of files divided in small group, indexed by that MICH_sweep_idx. Each PRCL_err matrix is supposed to be a slice of a 3D matrix.
When I run this script, I get x:
89.5500000000000
89.7100000000000
89.8700000000000
90.0300000000000
90.1900000000000
y:
82.3000000000000
82.5700000000000
82.8400000000000
83.1100000000000
83.3800000000000
83.6500000000000
which are correct, but PRCL_err is:
2.04785368637401 -0.667441223083977 -1.95353059779203e-05 -4.40930730761948e-09 6.83492839876029e-10
1.89484032129923 0.900835109003546 -2.36469244203520e-05 8.28824004397832e-09 -8.00730963205311e-06
0.348854333284356 0.144610298408358 1.71542544257776e-05 -1.32088244704865e-08 -6.03934183741016e-06
0.333111150398700 -0.0311437842552640 -8.80043467850152e-09 -7.43143221743052e-10 -3.81823564974252e-06
1.77262495054850 -4.28589800691167e-05 8.28481006834220e-09 -1.12096179287113e-09 -4.92022459209445e-06
1.67422184231239 1.47022175513420e-05 -3.44943817447404e-09 -8.57233231431145e-09 2.84915270006448e-06
As you can see, the numbers in this table are not those shown in the third column of the data file, and I can't figure out where do these come from.
The function convert3D was written by my advisor, and passed on to me for efficiency sake. I have tested it separately, and as far as I can tell it works as it is supposed to.
Even weirder is the fact that when she runs the code, it works just fine.
I'm using MATLAB 2020a on ubuntu 20.04.1
Thanks in advance.
EDIT:
While the solution provided by KSSV worked for a matrix containing only one signal, I encountered another problem when adding more outputs to the simulation I'm running. With 3 outputs, the simulation produces a 30x5 matrix printed on a .txt file (attached), but when I load it in the MATLAB script with the command:
DataMatrix = load(mySortedStruct(tilt_idx+k).name);
actually produces the following 30x25 matrix:
89.5500000000000 82.3000000000000 2.04785368637401 2.03969846384722 2.03127351876739 2.02258066345555 2.01362350504215 2.00440766517303 1.80228235026352 1.79281421385271 1.78309245547646 1.77312420468466 1.76291892159222 1.75248863999623 1.73593817224863 1.72554342530988 1.71497548909919 1.70425173090077 1.69339251918784 1.68242144617067 1.93597431797750 1.92574918360711 1.91546660019240 1.90515357151759 1.89484032129923
89.5500000000000 82.5700000000000 1.88456041696453 2.32384397361736 2.31445302845314 2.30507078975699 2.29572710077292 2.28645476560778 2.27728958882918 0.327513335341144 0.327088509746404 0.326663993043526 0.326241027583607 0.325820979653980 0.325405342359972 0.350417242239556 0.349898682931089 0.349377292880477 0.348854333284356 0.348331209339155 0.347809475407406 0.368062938031552 0.367446188733608 0.366822503852324 0.366193098879716
89.5500000000000 82.8400000000000 0.365559350409086 0.364922803745816 0.375578557915361 0.374893513529188 0.374196445212028 0.373488402685894 0.372770607441621 0.372044462904678 0.369123320045275 0.368446377210865 0.367752784179683 0.367043282171545 0.366318781690702 0.365580375065833 0.295950603146901 0.295719328101584 0.295511674861340 0.295330075602522 0.295177064313788 0.295055264507923 0.316647459727925 0.316342146721891 0.316059179415000
89.5500000000000 83.1100000000000 0.315801077845019 0.315570478477032 0.315370122820907 0.332592628512978 0.332206792285260 0.331840765615770 0.331497072605989 0.331178365099130 0.330887412509211 0.339383935459690 0.338939873133786 0.338511490502372 0.338101168674883 0.337711421896284 0.337344889022034 0.333550891153579 0.333111150398700 0.332682444414565 0.332266840671548 0.331866534678902 0.331483843468989 1.57724711852224 1.59659536221434
89.5500000000000 83.3800000000000 1.61599958594742 1.63542859719209 1.65484834474908 1.67422184231239 1.68759812748023 1.70798736328788 1.72841243185240 1.74883894891172 1.76922954188472 1.78954379107665 1.77262495054850 1.79368947710108 1.81476255246863 1.83580667988707 1.85678127891171 1.87764264830754 1.80885432094290 1.83007741765499 1.85127743339487 1.87241413280263 1.89344414609337 1.91432095647933 1.77778682585609
89.5500000000000 83.6500000000000 1.79862754008305 1.81942117496183 1.84012577060656 1.86069621115770 1.88108423275009 1.88836665292140 1.88161876297512 1.87455092401992 1.86715813193390 1.85943670838643 1.85138450903579 1.26324284031156 1.25724597529788 1.25086429277327 1.24408600403964 1.23690034252825 1.22929779999512 0.390975603601925 0.386970527038904 0.382543737410426 0.377675875284042 0.372348081466137 0.366542240819562
89.7100000000000 82.3000000000000 -0.664916327405932 -0.665355471656391 -0.666188354896463 -0.667441223083977 -0.669140567440748 -0.671312901610047 -1.70086959935128 -1.69729024643695 -1.69399105074557 -1.69100131259761 -1.68835142103087 -1.68607269005896 1.35990107260622 1.35504059971539 1.34994973572424 1.34462487721443 1.33906337543532 1.33326368622200 0.909753523826245 0.905432865376069 0.900835109003546 0.895951765834762 0.890775083004180
89.7100000000000 82.5700000000000 0.885298213733071 0.281622903678263 0.278735821530081 0.275545077890968 0.272036732372002 0.268197204793117 0.264013450749952 -0.478755583912177 -0.479074956167115 -0.479677843171629 -0.480583144107751 -0.481809934763162 -0.483377307067957 -1.22479336738116 -1.22221837430057 -1.21984510724147 -1.21769466473654 -1.21578892926995 -1.21415044937086 -0.160528760683684 -0.159955865706733 -0.159355763024501 -0.158728026558840
89.7100000000000 82.8400000000000 -0.158072342904583 -0.157388529031433 -0.107379154579523 -0.106869769383933 -0.106327664363656 -0.105751836598153 -0.105141370007512 -0.104495455432919 -0.0332209077534806 -0.0328804336026791 -0.0325041073952467 -0.0320902826121508 -0.0316373551915895 -0.0311437842552640 0.0565444119825121 0.0565821909553986 0.0566534377589168 0.0567603842095610 0.0569052830542158 0.0570903890296431 0.144610298408358 0.144306857183605 0.144027222203769
89.7100000000000 83.1100000000000 0.143773884662102 0.143549428384265 0.143356515914624 -4.31501135744917e-05 -4.30773314410420e-05 -4.30044389968487e-05 -4.29315968541333e-05 -4.28589800691167e-05 -4.27867784376488e-05 -4.33246894017237e-05 -4.32231865244886e-05 -4.31198919615870e-05 -4.30149332585028e-05 -4.29084574143833e-05 -4.28006318627129e-05 -3.85775851591970e-05 -3.84739844841743e-05 -3.83668153206755e-05 -3.82561074201691e-05 -3.81419109660300e-05 -3.80242984033576e-05 -2.92184652977806e-05 -2.91462835075899e-05
89.7100000000000 83.3800000000000 -2.90696573458104e-05 -2.89884898242372e-05 -2.89026991864349e-05 -2.88122213253957e-05 -1.80179695355624e-05 -1.79927984271966e-05 -1.79636666891133e-05 -1.79303848560401e-05 -1.78927691766369e-05 -1.78506439909208e-05 2.18235805604359e-05 2.17867613687977e-05 2.17498864520295e-05 2.17130370379621e-05 2.16763016594862e-05 2.16397763040767e-05 2.19117637231944e-05 2.18604185720004e-05 2.18081673768390e-05 2.17550746425722e-05 2.17012147126865e-05 2.16466722652649e-05 1.95108618810284e-05
89.7100000000000 83.6500000000000 1.94584561163745e-05 1.94042457123544e-05 1.93482457160563e-05 1.92904815079595e-05 1.92309897273465e-05 1.47774939719242e-05 1.47409795735912e-05 1.47022175513420e-05 1.46611588553987e-05 1.46177621395219e-05 1.45719949837183e-05 9.11289631260681e-06 9.10015942486428e-06 9.08541953327250e-06 9.06858081869991e-06 9.04955035205828e-06 9.02823929666867e-06 -1.52911166499510e-05 -1.52801347347200e-05 -1.52702178520220e-05 -1.52614755425941e-05 -1.52540228062529e-05 -1.52479797608093e-05
89.8700000000000 82.3000000000000 -1.95602203161730e-05 -1.95353059779203e-05 -1.95111547499471e-05 -1.94878866115834e-05 -1.94656294030417e-05 -1.94445186879040e-05 -2.30383570038830e-05 -2.29970536108783e-05 -2.29558874840044e-05 -2.29149747017301e-05 -2.28744417624265e-05 -2.28344257604340e-05 -2.46628930128483e-05 -2.46112732463698e-05 -2.45589375737927e-05 -2.45059726887597e-05 -2.44524773203297e-05 -2.43985628149723e-05 -2.39024747958107e-05 -2.38541060983193e-05 -2.38043253295726e-05 -2.37531680790234e-05 -2.37006813299478e-05
89.8700000000000 82.5700000000000 -2.36469244203520e-05 1.14671900737802e-05 1.14589529255387e-05 1.14515144695454e-05 1.14449568512456e-05 1.14393663097728e-05 1.14348329221565e-05 1.46687542993883e-05 1.46500673469117e-05 1.46319526928070e-05 1.46145003114609e-05 1.45978060721550e-05 1.45819716359307e-05 1.72771972145412e-05 1.72462180397865e-05 1.72153418477168e-05 1.71846556883555e-05 1.71542544257776e-05 1.71242408701355e-05 1.84955963161651e-05 1.84568792018281e-05 1.84176252595067e-05 1.83778995036733e-05
89.8700000000000 82.8400000000000 1.83377759744985e-05 1.82973381742962e-05 1.79254252298303e-05 1.78891454771761e-05 1.78518068066522e-05 1.78134359084784e-05 1.77740680175669e-05 1.77337476341370e-05 -8.84688183218706e-09 -8.83143768102216e-09 -8.81594451064248e-09 -8.80043467850152e-09 -8.78494356131153e-09 -8.76950962757240e-09 -8.81316163430779e-09 -8.79189985898208e-09 -8.77023787691411e-09 -8.74820072224463e-09 -8.72581745815925e-09 -8.70312139117155e-09 -7.75873685414911e-09 -7.73731187455530e-09 -7.71512186072585e-09
89.8700000000000 83.1100000000000 -7.69217116175011e-09 -7.66846831248057e-09 -7.64402642190949e-09 -5.76668884977914e-09 -5.75206409892744e-09 -5.73650337235345e-09 -5.71998467612541e-09 -5.70248907417806e-09 -5.68400119424139e-09 -3.42648021008729e-09 -3.42173643668740e-09 -3.41616984001210e-09 -3.40973964258181e-09 -3.40240612290004e-09 -3.39413110724186e-09 1.24133754217238e-08 1.23920996846150e-08 1.23707814074191e-08 1.23494665333685e-08 1.23282051869898e-08 1.23070517644665e-08 1.24320614636207e-08 1.24025486761655e-08
89.8700000000000 83.3800000000000 1.23725071733079e-08 1.23419731518921e-08 1.23109884230072e-08 1.22796006998714e-08 1.10302214181483e-08 1.10002258351908e-08 1.09691903497971e-08 1.09371227616324e-08 1.09040367470631e-08 1.08699523911986e-08 8.30559521000744e-09 8.28481006834220e-09 8.26273672409680e-09 8.23934637516276e-09 8.21461457427113e-09 8.18852192880260e-09 5.06451668294840e-09 5.05738375802096e-09 5.04910754822710e-09 5.03963273230913e-09 5.02890558506400e-09 5.01687466307488e-09 -2.65648094362893e-09
89.8700000000000 83.6500000000000 -2.65505145598575e-09 -2.65383911711698e-09 -2.65286416486363e-09 -2.65214771822716e-09 -2.65171169921265e-09 -3.44943817447404e-09 -3.44545857685765e-09 -3.44164697370251e-09 -3.43802602952373e-09 -3.43461974496074e-09 -3.43145341225524e-09 -4.12504613971609e-09 -4.11800040388691e-09 -4.11101419263696e-09 -4.10411008635643e-09 -4.09731250039496e-09 -4.09064769560243e-09 -4.49367211491891e-09 -4.48450169478651e-09 -4.47523757692796e-09 -4.46589771602731e-09 -4.45650225102251e-09 -4.44707358933834e-09
90.0300000000000 82.3000000000000 -4.44647293898865e-09 -4.43751139755641e-09 -4.42832344991368e-09 -4.41891830250992e-09 -4.40930730761948e-09 -4.39950411972024e-09 5.47116997688792e-09 5.46752921253021e-09 5.46429113113261e-09 5.46149574099102e-09 5.45918495900252e-09 5.45740247598007e-09 7.03650648081550e-09 7.02777307997524e-09 7.01933667565125e-09 7.01124142797325e-09 7.00353429116495e-09 6.99626495056975e-09 8.33227539668734e-09 8.31750931986987e-09 8.30281648053000e-09 8.28824004397832e-09 8.27382692288446e-09
90.0300000000000 82.5700000000000 8.25962782698897e-09 8.97428506256257e-09 8.95558896908575e-09 8.93665729261583e-09 8.91752299958510e-09 8.89822342911784e-09 8.87880049028021e-09 8.76076815696291e-09 8.74299395834213e-09 8.72472687909519e-09 8.70598166864820e-09 8.68677726905490e-09 8.66713715227473e-09 -1.32567100850566e-08 -1.32325391180399e-08 -1.32088244704865e-08 -1.31856459551572e-08 -1.31630886119820e-08 -1.31412426847547e-08 -1.30890916562383e-08 -1.30524264035936e-08 -1.30156622093619e-08 -1.29788719855126e-08
90.0300000000000 82.8400000000000 -1.29421356695035e-08 -1.29055404127667e-08 -1.13881263314069e-08 -1.13469797311731e-08 -1.13050991699343e-08 -1.12625301685984e-08 -1.12193259497418e-08 -1.11755478848792e-08 -8.31942696385883e-09 -8.28496789145640e-09 -8.24937161220046e-09 -8.21264548227859e-09 -8.17480347614251e-09 -8.13586682877452e-09 -4.78622787340123e-09 -4.76474361575697e-09 -4.74211720822169e-09 -4.71832534414719e-09 -4.69334895394212e-09 -4.66717388201493e-09 -1.14297188724272e-09 -1.14085430981401e-09 -1.13875754564973e-09
90.0300000000000 83.1100000000000 -1.13668800099145e-09 -1.13465253078523e-09 -1.13265844369835e-09 -1.13974473911921e-09 -1.13602159096217e-09 -1.13227567780912e-09 -1.12851274439197e-09 -1.12473913051394e-09 -1.12096179287113e-09 -1.00328775329066e-09 -9.98597286467246e-10 -9.93834889205855e-10 -9.89003884409664e-10 -9.84108244482723e-10 -9.79152634138514e-10 -7.43143221743052e-10 -7.38596598878016e-10 -7.33948912830739e-10 -7.29200152108426e-10 -7.24350860960959e-10 -7.19402198120321e-10 -4.36860118222605e-10 -4.33265134786408e-10
90.0300000000000 83.3800000000000 -4.29572850877572e-10 -4.25780600936107e-10 -4.21886070879306e-10 -4.17887359369905e-10 -5.55393432670381e-09 -5.56033463462376e-09 -5.56761841027280e-09 -5.57583713661714e-09 -5.58504284883090e-09 -5.59528771687152e-09 -7.04454570694171e-09 -7.04410547755334e-09 -7.04445920636677e-09 -7.04566722118620e-09 -7.04779171801714e-09 -7.05089642981458e-09 -8.27066488256611e-09 -8.26192943548592e-09 -8.25375681241786e-09 -8.24621023594426e-09 -8.23935620443234e-09 -8.23326429717651e-09 -8.86051183932052e-09
90.0300000000000 83.6500000000000 -8.84527762706907e-09 -8.83026331973162e-09 -8.81552469620625e-09 -8.80112188141404e-09 -8.78711932942513e-09 -8.62285693329422e-09 -8.60609943455446e-09 -8.58924492425026e-09 -8.57233231431145e-09 -8.55540510021797e-09 -8.53851152031182e-09 5.63433288689637e-10 5.61665481900953e-10 5.59961938558369e-10 5.58327356298348e-10 5.56766656870894e-10 5.55284966072806e-10 6.46010893493864e-10 6.43771107226872e-10 6.41581486779681e-10 6.39447054751714e-10 6.37373164454518e-10 6.35365490377083e-10
90.1900000000000 82.3000000000000 6.88753882480716e-10 6.86111321652101e-10 6.83492839876029e-10 6.80903183844361e-10 6.78347530457209e-10 6.75831491239476e-10 6.65181802457138e-10 6.62508356383555e-10 6.59825858971367e-10 6.57137876852149e-10 6.54448459760614e-10 6.51762161001359e-10 5.74037772115213e-10 5.71842913190099e-10 5.69613213486307e-10 5.67350425169992e-10 5.65056752065078e-10 5.62734883721490e-10 -7.93255201500691e-06 -8.00730963205311e-06 -8.08121468198444e-06 -8.15403454629148e-06 -8.22552045146340e-06
90.1900000000000 82.5700000000000 -8.29540722121450e-06 -8.03588405453545e-06 -8.13833263399813e-06 -8.24066638191720e-06 -8.34264748289366e-06 -8.44402009122535e-06 -8.54451009624130e-06 -7.13265064732802e-06 -7.26099616364611e-06 -7.39030484493362e-06 -7.52034592122254e-06 -7.65086736798204e-06 -7.78159556241496e-06 -5.30366995957688e-06 -5.44674038107120e-06 -5.59205217543863e-06 -5.73940849681624e-06 -5.88858754868852e-06 -6.03934183741016e-06 -3.12320715691135e-06 -3.26444909065551e-06 -3.40909106065259e-06 -3.55700145776700e-06
90.1900000000000 82.8400000000000 -3.70802163481622e-06 -3.86196448996961e-06 -2.03827907633945e-06 -1.94612407205680e-06 -1.84927906344976e-06 -1.74760372843178e-06 -1.64096433806825e-06 -1.52923533962388e-06 -4.16630694832197e-06 -4.08709971675627e-06 -4.00280470958389e-06 -3.91324149790359e-06 -3.81823564974252e-06 -3.71762040697284e-06 -6.29035148461398e-06 -6.23777327048748e-06 -6.17996651678524e-06 -6.11669655441905e-06 -6.04773309289373e-06 -5.97285215782668e-06 -7.70802161111027e-06 -7.69227961971951e-06 -7.67165416676364e-06
90.1900000000000 83.1100000000000 -7.64585238558886e-06 -7.61458178807882e-06 -7.57755245487446e-06 -8.04506401627391e-06 -8.06677104859854e-06 -8.08448152337124e-06 -8.09786188503319e-06 -8.10657257873539e-06 -8.11027021028802e-06 -3.22360465417077e-06 -3.18448127731643e-06 -3.14150729098591e-06 -3.09445129824647e-06 -3.04307819285812e-06 -2.98715078956985e-06 -4.05632006937450e-06 -4.03465840903369e-06 -4.00954518405284e-06 -3.98073526192813e-06 -3.94797634134936e-06 -3.91101025475720e-06 -4.70745291417245e-06 -4.70462886237080e-06
90.1900000000000 83.3800000000000 -4.69890138619764e-06 -4.69002255224635e-06 -4.67773426584714e-06 -4.66176921791490e-06 -5.00525895297102e-06 -5.02086170885505e-06 -5.03421566038905e-06 -5.04508045838886e-06 -5.05320322304586e-06 -5.05831913843125e-06 -4.85991047112059e-06 -4.89083832612408e-06 -4.92022459209445e-06 -4.94784604532992e-06 -4.97346514260737e-06 -4.99683026987954e-06 4.57511487697888e-06 4.67051688033997e-06 4.76795466370357e-06 4.86733093188757e-06 4.96852743241033e-06 5.07140308255075e-06 3.79250577289763e-06
90.1900000000000 83.6500000000000 3.89014051920873e-06 3.99036310408488e-06 4.09311973644777e-06 4.19833738203146e-06 4.30592173637014e-06 2.75387120217605e-06 2.84915270006448e-06 2.94744701805647e-06 3.04874439387734e-06 3.15301819478938e-06 3.26022281702738e-06 1.55320705436964e-06 1.64087145612480e-06 1.73180539662272e-06 1.82604025854010e-06 1.92359330535366e-06 2.02446557798094e-06 4.21524479606478e-07 4.96753593923537e-07 5.75314493147560e-07 6.57275023939719e-07 7.42691923055767e-07 8.31608763615543e-07
It's a 30x25 matrix that contains the correct values distributed on "horizontally" on the columns after the second one, but once these values runs out, the rest of the matrix is filled with these small numbers that I have no idea where they are coming from.
  2 Comments
Mattia Boldrini
Mattia Boldrini on 10 Sep 2020
that is exactly my problem, I have no idea. By adding two more outputs I should get a 30x5 matrix.

Sign in to comment.

Accepted Answer

KSSV
KSSV on 9 Sep 2020
Let A be your given m*3 data.
x = A(:,1) ; y = A(:,2) ; z = A(:,3) ;
xi = unique(x) ; yi = unique(y) ;
[X,Y] = meshgrid(xi,yi) ;
Z = reshape(z,size(X)) ;
figure
surf(X,Y,Z)
  6 Comments
Mattia Boldrini
Mattia Boldrini on 10 Sep 2020
i think i understood: there was a name overlap between this file and another file containing the 30x25 matrix, produced by the same simulation yesterday. I thought that getting the directory would solve the ambiguity, but evidently no. Given this, your aswer was indeed correct. Thank you and sorry for the mistake.
KSSV
KSSV on 10 Sep 2020
Yes I thought the same...mistake might be in:
DataMatrix = load(mySortedStruct(tilt_idx+k).name);

Sign in to comment.

More Answers (0)

Products


Release

R2020a

Community Treasure Hunt

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

Start Hunting!