Interpolate both dataset on a same grid
이전 댓글 표시
Hi, i have the two different datasets (PFA the excel file) as following
Dataset A size (119*177) with each lat and long file of same size
Dataset B size (145*73) with long size of (145*1) and lat size of (73*1)
The steps according to my understanding are-
- Make a lat, long file for dataset B of size (145*73) - question how to do that?
- Interpolate the dataset A to the size of Dataset B, which i am guessing using interp2
댓글 수: 5
Jan
2018년 3월 19일
What are your inputs? "PFA the excel file" is not clear. Are the "data set" simply matrices? Do you really need to "make a file"?
Sophia
2018년 3월 19일
Jan
2018년 3월 19일
Is importing the Excel file a part of your problem? If not, wouldn't it be less confusing to start with: A = rand(199, 177), B = rand(145, 73)? Does it matter that I do not know what "PFA" means? But it does matter, on which grid the data are recorded. Maybe the X positions of A go from 1 to 177, while the positions of B go from -35 to 37. Before we can suggest a method to apply the grids to A and B, you have to explain the details.
Sophia
2018년 3월 19일
Jan
2018년 3월 20일
An abbreviation for the first part:
nlong = repmat(lat, mm, 1);
nlat = repmat(long(:), 1, nn);
But you do not need to create matrices with the grid coordinates, because interp2 accepts vectors directly.
See my answer...
답변 (2개)
I assume that this helps:
B = rand(145, 73);
A = rand(119, 177);
y = linspace(1, 145, 199);
x = linspace(1, 73, 177);
BB = interp2(1:73, (1:145).', B, x, y.');
Now BB is the linear interpolation of B with the same size as A.
Note: I still find the order of the coordinates for interp2 counter-intuitive:
Vq = interp2(V,Xq,Yq) assumes X=1:N and Y=1:M where [M,N]=SIZE(V)
I'd expect the 1st input to be correlated to size(V, 1) and the 2nd to size(V,2), but MathWorks decided to swap the order. This is at least consistent with e.g. gradient.
댓글 수: 1
Sophia
2018년 3월 19일
편집: John D'Errico
2018년 3월 20일
0 개 추천
댓글 수: 6
Jan
2018년 3월 20일
@sophia: MathWorks did not publish your personal mail address. On your profile page, you have enabled the possibility to contact you through the forum's interface: https://www.mathworks.com/matlabcentral/profile/authors/5688027-sophia - see the "Contact" button below you profile picture on the left. On the setup of your profile you can deselect the "Allow users to contact me securely" checkbox, if you do not want this.
Unfortunately having this contact service enable means, that you get a lot of time wasting messages: "Solve my homework ASAP!", "Didn't you read my question?", "I offer 5$ for solving my final project" and "Send me code for simulating an X-boson vector search for anti-matter delta distributions in the co-valent subspace using the most modern KI system."
Stephen23
2018년 3월 20일
"I am worried how come MATHWORKS can share my personal email with any random person"
Just to make it clear: that person does NOT have your email address! They sent a message via your user profile, and the email was sent by TMW on their behalf. If you reply to that email then that user will then have your email address.
John D'Errico
2018년 3월 20일
편집: John D'Errico
2018년 3월 20일
I'm sorry to see you had this spam sent to you. As Jan and Stephen said, your address is NOT made public. But they do offer a way for people to contact you, and now it seems that someone is using that service as a means to spam people.
It seems this person is now beginning to harass people with their spam. You are the second person to have reported the offer of work for pay, which now implies they are doing it to many people. After all, if two people are so upset that they complain online, there are hundreds of people who will have been affected.
I'll report the problem to the proper authority, as I did the last time I saw someone complain. I hope we can help to prevent more such spam being generated from people's accounts.
Jan
2018년 3월 20일
Offering a programming service in a Matlab forum is not completely off-topic, such that I'm not sure if this should be classified as spam. But of course the nature of the forum is sharing solutions in public, therefore I do not like such advertisements.
But I strongly recommend not to click on any bit.ly link, which is sent without a request by mail or through the contact form of this forum. This could be a cheap trick to let you open an infected page.
"Offering a programming service in a Matlab forum is not completely off-topic"
1.e "You agree ... nor to use the communication systems provided by the Site (e.g., comments) for any commercial solicitation purposes."
2.a.iv "You may not use the Site to sell or market your products or services to others."
Sophia
2018년 3월 20일
카테고리
도움말 센터 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!