How to get Y values corresponding to X from matrix B nx2 or from X and Y matrices
조회 수: 1 (최근 30일)
이전 댓글 표시
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
채택된 답변
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Discrete Data Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!