could anyone help me please

anyone can help me why is this error happened? and why do variable a and b have different matrix result?

5 Comments

John D'Errico
John D'Errico on 9 Mar 2018
Edited: John D'Errico on 9 Mar 2018
Do you seriously expect anyone to be able to read what you have posted? Could you not have posted the ACTUAL text of your code, and then the actual error message, as text, pasted in?
When you edit your question, be sure to attach the relevant files so we can run you code with realistic data. And are you 100% sure that b will always have 365 elements?
clear;clc;
[x,h]=importdata('E:\Skripsi\koordinat\koordinatsesuaibatas.txt'); % semua koordinat CHIRPS yang dipakai
x1=importdata('E:\Skripsi\Data chirps\chirps_daily_1986_Kalteng.txt');%x1=xx'; % Error hasil interpolasi dan koordinat
[m,n]=size(x);
for i=1:m
aa=abs(x1(:,1)-x(i,1));
a=find(aa==min(aa));
bb=abs(x1(a,2)-x(i,2));
b=find(bb==min(bb));
data(i,:)=x1(a(b),:);
end
dlmwrite('E:\Skripsi\Bias Koreksi\Chirps1423Grid.txt',data,'\t')
Subscripted assignment dimension mismatch.
Error in PotongGrid_chirps (line 11)
data(i,:)=x1(a(b),:);
Ardi - put a breakpoint at the line
data(i,:)=x1(a(b),:);
and run your code. Look at the dimensions of data and that of x1 and in particular x1(a(b),:). Given the sizes of the source and target, does this line of code make sense?

Sign in to comment.

Answers (1)

Steven Lord
Steven Lord on 9 Mar 2018
Your array bb has two or more elements that are exactly equal to the minimum value. That means b will have two or more elements and so will a(b). You're trying to assign multiple rows of x1 into one row of the variable named data, and that won't work. You can't fit two dozen eggs into an egg carton designed to hold one dozen (at least not intact.)
You probably want to call min on bb with two outputs and use the second output of that call as the index into a.

Tags

Asked:

on 9 Mar 2018

Answered:

on 9 Mar 2018

Community Treasure Hunt

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

Start Hunting!