Info
Questa domanda è chiusa. Riaprila per modificarla o per rispondere.
How to extract the same row, column 2 value by inputting the column 1 value
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
I have created a matix from a smoothed spline interpolation called SS(see below), I now need to be able to have matlab reference the T value from the same row in that matrix when it is given an x value how can I do this?
clc
clear
lengthX = 100;
x=[0 20 40 60 65 70 75 80 85 90 95 100]';
T=[150 176 212 268 282 289 296 290 262 200 100 0]';
samplingRateIncrease = 395.89;
newXSamplePoints = linspace(1, lengthX, lengthX * samplingRateIncrease);
smoothedT = spline(x, T, newXSamplePoints);
x1= 1.57*newXSamplePoints;
Tm1 = 100.519*smoothedT;
SS = [Tm1', x1'];
0 Commenti
Risposte (1)
Jemima Pulipati
il 21 Ott 2020
From my understanding, you want to print the corresponding Tm1 value of a specific x1 value from the SS matrix.
Here is a sample code.
clc
clear
lengthX = 100;
x=[0 20 40 60 65 70 75 80 85 90 95 100]';
T=[150 176 212 268 282 289 296 290 262 200 100 0]';
samplingRateIncrease = 395.89;
newXSamplePoints = linspace(1, lengthX, lengthX * samplingRateIncrease);
smoothedT = spline(x, T, newXSamplePoints);
x1= 1.57*newXSamplePoints;
Tm1 = 100.519*smoothedT;
SS = [Tm1', x1'];
% calculating index of rows with a specific column value
% here a hardcoded x1 value is provided as the specific column value
index = SS(:,2) == 1.573926189754471;
% printing the corresponding Tm1 value
SS(index,1)
This code checks for the index of rows which have the column values as '1.573926189754471' and prints the Tm1 values of those rows. Since the values of SS matrix are unique there would be only one Tm1 value displayed always.
The result of the above code is
ans =
1.5208e+04
You can refer to this link for more information on how to perform Matrix indexing
0 Commenti
Questa domanda è chiusa.
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!