How to get Y values corresponding to X from matrix B nx2 or from X and Y matrices
11 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
We have the data of matrix B (201x2) which consist of x_i (1x201) and y_i (1x201) matrices.
We want program to prompt y_i value corresponding to x_i value that we will write.
I'm open for other solutions too.
(Don't mind the part before %%%% INTERP1 %%%% )
clear all;
close all;
clc;
h=openfig('Fig2m005.fig'); %%%% Load graphic
h=findobj(gca,'Type','line'); %%%% Make program read graphic
x=get(h,'Xdata'); %%%% Values
y=get(h,'Ydata');
A=[]; %%%% Create empty matrix so you can put x and y
A(:,1)=x; %%%% Put x values to 1st column
A(:,2)=y; %%%% Put y values to 2st column
dlmwrite('m005.txt',A,','); %%%% Write A matrix as a txt text file, value that we selected by hand
%%%% INTERP1 %%%%
x_i = 0:0.0001:0.02;
y_i = interp1(x, y, x_i, 'linear');
B=[];
B(:,1)=x_i;
B(:,2)=y_i;
dlmwrite('m005_interp1.txt',B,',');
figure(2) %%%% Creates new window for new interpolated graph ( as you can see there is no difference )
plot(x_i, y_i,'g') %%%% line names in data file
title('Dimensionless design breaker height versus relative depth at structure') %% naming
xlabel('ds/gT^2')
ylabel('Hb/ds')
axis ([0 0.02 0 2])
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Functions finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!