Interpolate both dataset on a same grid
Show older comments
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 Comments
Jan
on 19 Mar 2018
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
on 19 Mar 2018
Jan
on 19 Mar 2018
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
on 19 Mar 2018
Jan
on 20 Mar 2018
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...
Answers (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 Comment
Sophia
on 19 Mar 2018
Edited: John D'Errico
on 20 Mar 2018
0 votes
6 Comments
Jan
on 20 Mar 2018
@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
on 20 Mar 2018
"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
on 20 Mar 2018
Edited: John D'Errico
on 20 Mar 2018
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
on 20 Mar 2018
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
on 20 Mar 2018
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!