I have a data set...like say CAD from 212 to 550 say with a differnce of 1 and have corresponing SA values to these CAD values
But I want to pick numbers at a specific distance and in a specific sequence ..like 212,212.3,212.7,213,213.3,213.7.....so that later on i can interpolate the SA values on these CAD values.
How can i do that!! if there was single difference between numbers that would be simple as i did here picking data with a differenc of 0.5:
CAD= data(:,1);
SA= data(:,2);
CADQ=CAD(1):0.5:CAD(end);
vq = interp1 (CAD, SA, CADQ);
here i was able to pick 212,212.5,213,213.5....and was able to interpolate SA on these CAD values.
now how can i do that..picking CAD data in the sequence 212,212.3,212.7,213,213.3,213.7,214,214.3.....

1 件のコメント

Rik
Rik 2021 年 3 月 15 日
I don't understand your question well enough to answer it, but it sounds as if ismember will be helpful.

サインインしてコメントする。

 採用された回答

Steven Lord
Steven Lord 2021 年 3 月 15 日

0 投票

One way is to take advantage of implicit expansion.
x = 212:215;
y = [0; 0.3; 0.7];
z = reshape(x+y, 1, [])
z = 1×12
212.0000 212.3000 212.7000 213.0000 213.3000 213.7000 214.0000 214.3000 214.7000 215.0000 215.3000 215.7000

5 件のコメント

Usama Bin Khalid
Usama Bin Khalid 2021 年 3 月 15 日
Its working for the instance but its not following the sequence...you understand what i mean,...i.e if i put here
[ 0;0.3;0.8 ], it will generate 212 212.3 212.8 213 213.3 213.8
but i wanted was to follow like this
212 212.3 212.8 213.1 213.6 213.9.... like addition of 0.3 then 0.5 then 0.3 then 0.5...
ok i will uplaod a sample data here: .. and re-question my question:
I want to get values of SA at CAD 213,213.3,213.7,214,214.3,214.7,215,215.3.....so on...just on these points.. so when i will get these i will interpolate SA values on them
CAD SA.
213 0.028698539
213.46 0.028679289
213.76 0.028659992
214.46 0.028640648
214.76 0.028621256
215.46 0.028601818
215.76 0.028582333
216.46 0.028562802
216.76 0.028543223
so on.....
if i implement your code it will give the values that i dont need like it will start adding 0.3,0.4 into 213.46 and so on.. i hope now my question is understadable..
Rik
Rik 2021 年 3 月 15 日
編集済み: Rik 2021 年 3 月 15 日
repmat with cumsum should do the trick.
Usama Bin Khalid
Usama Bin Khalid 2021 年 3 月 15 日
please elaboarte with a code or algorithm..that will be helpful...
Rik
Rik 2021 年 3 月 15 日
Create an array where you repeat 0.3 0.5 enough times, set your starting offset as the first value and then use cumsum to calculate the cumulative sum.
x=repmat([0.3 0.5],1,5)
x = 1×10
0.3000 0.5000 0.3000 0.5000 0.3000 0.5000 0.3000 0.5000 0.3000 0.5000
x(1)=213
x = 1×10
213.0000 0.5000 0.3000 0.5000 0.3000 0.5000 0.3000 0.5000 0.3000 0.5000
x=cumsum(x)
x = 1×10
213.0000 213.5000 213.8000 214.3000 214.6000 215.1000 215.4000 215.9000 216.2000 216.7000
Usama Bin Khalid
Usama Bin Khalid 2021 年 3 月 15 日
Yes it worked perfectly...so we can use this code to interpolate any repetitive values....Thanks

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File Exchange で Programming についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by