Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
i keep getting the error "Error using -""Matrix dimensions must agree"
for this piece of code. Can anybody help me and identify where i'm going wrong? I should be getting 8 plots of f vs d.
P=500;
N=1:1:8;
a=-0.4;
b=-1;
Kd=700;
d50star=(1./(10.^(Kd*(N.^a)*(P-115).^b)))
w0=0.45;
d=0:0.1:10
d50N0=5;
if d50star < 0.33;
w=(1-(2.3*d50star))*w0
else
w=(3.4-(5.5*d50star))*w0
end
d50=(1-d50star)*d50N0;
f=1-(1./((1+exp((d-d50)/w))))
There are at least two errors in the script:
1) in the last line [f=1-(1./((1+exp((d-d50)/w))))]
d size is 1x101
d50 size is 1x8
The size inconsistency is related to the definition of:
N=1:1:8; and
d=0:0.1:10
2) depending on the algoroth, it could be ./w instead of /w
Hope this helps.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Closed 9 years ago.
Improve this question
I'm using the computer vision: VLfeat library to compute a HOG descriptor of an image, and after inputing this code:
cellSize = 8 ;
hog = vl_hog(im, cellSize, 'verbose') ;
I get this error in MATLAB, and when I google it I really can't find any possible explanation:
Error using vl_hog
I is not a real numeric array of class SINGLE.
After going over the code (found here) I'm also not sure what the variable I is:
Hopefully, I haven't missed something elementary ...
library source
As the asker already found out, the I refers to the first input argument.
Hence this should solve the problem:
hog = vl_hog(single(im), cellSize, 'verbose')
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Closed 9 years ago.
Improve this question
Help I'm developing an application in matlab using the Vertcat functon.
But I got this error in Matlab..
??? Error using ==> vertcat
CAT arguments dimensions are not consistent.
Error in ==> imgMaskMed at 31
copy_matrix = vertcat(copy_matrix, copy_matrix(a_temp,:));
Here is my code where the error located
copy_matrix = vertcat(copy_matrix, copy_matrix(a_temp,:));
What is wrong with my code?
It's hard to know with the little information you provide, but my guess is that your copy_matrix has more than 2 dimensions. For example, if it's a 3D array you should use
copy_matrix = vertcat(copy_matrix, copy_matrix(a_temp,:,:));
If it's 4D use
copy_matrix = vertcat(copy_matrix, copy_matrix(a_temp,:,:,:));
and so on.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
When i run my program for 4 iterations there is no problem but if i run it for more than 4 i get the following error
In an assignment A(I) = B, the number of elements in B
and
I must be the same.
for the following line
Corresponding_value_of_x1(i)=x1(f==Lowest_value_of_the_objective_function(i));
Please help.
maxit=5
iga=1
x1=(6.*bin2dec(String_1))./1023
x2=(6.*bin2dec(String_2))./1023
for i=1:1:maxit
f=(x1.^2+x2-11).^2+(x1+x2.^2-7).^2;
%Displaying results from the iteration
i;
Lowest_value_of_the_objective_function(i)= min(f);
Corresponding_value_of_x1(i)=x1(f==Lowest_value_of_the_objective_function(i));
nx1=(6.*bin2dec(New_string(1)))./1023;
nx2=(6.*bin2dec(New_string(2)))./1023;
x1=nx1;
x2=nx2;
end
Corresponding_value_of_x1
It looks like you're trying to find the minimum of a vector, then the corresponding location of that value. min will do all that at once, avoiding the problem you're running into:
[Lowest_value_of_the_objective_function(i) Corresponding_value_of_x1(i)] = min(f);
Note that your error is occurring because the same minimum value is appearing more than once. This code will return the first of those minimum values. If you want different behavior, you'll have to code it.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Closed 9 years ago.
Improve this question
i have a problem with using the number of iteration in MATLAB.
i use this code but there is no change in the number of iteration:
Edit
this is my code...
clc;clear;close all;diary temp;
cluster_data=unifrnd(-3,+3,[100 2]);
optns = statset('MaxIter',500);
[idx,ctrs]=kmeans(cluster_data,3,'dist','city', ...
'display','iter','replicate',100,'options',optns);
figure
plot(cluster_data(idx==1,1),cluster_data(idx==1,2),'r.','MarkerSize',14)
hold on
plot(cluster_data(idx==2,1),cluster_data(idx==2,2),'b.','MarkerSize',16)
plot(cluster_data(idx==3,1),cluster_data(idx==3,2),'g.','MarkerSize',18)
plot(ctrs(:,1),ctrs(:,2),'kx',...
'MarkerSize',12,'LineWidth',2)
plot(ctrs(:,1),ctrs(:,2),'ko',...
'MarkerSize',12,'LineWidth',2)
legend('Cluster 1','Cluster 2','Cluster 3','Centroids',...
'Location','NW')
fid=fopen('temp');
dat=textscan(fid,'%s');
fclose(fid);
delete temp
dat=dat{1};
i1=find(~cellfun('isempty',strfind(dat,'sum')));
ie=find(~cellfun('isempty',strfind(dat,'iterations')));
i1=i1(1)+1;
Nd=str2num(dat{ie(1)-1});
ie=Nd*4+i1-1;
dat=reshape(str2num(strvcat(dat{i1:ie})),4,Nd)';
iter = dat(:,1) % <-- iterations
sm = dat(:,4) % <-- sum
figure
plot(iter,sm)
the issue is the number of iteration... how can i really increase the number of iteration?
however i increase the 'Maxiter' but no change appear.
You should use statset to change the number of iterations:
optns = statset('MaxIter',500);
And the call kmeans like this:
[idx,ctrs]=kmeans(cluster_data,3,'dist','city', ...
'display','iter','replicate',100,'options',optns);
Comment
The documentation for kmeans states:
MaxIter - Maximum number of iterations allowed. The default is 100.
So if you change the value of MaxIter it should be a number different from 100.