Error using / Matrix dimensions must agree...
252 ビュー (過去 30 日間)
古いコメントを表示
Below is my script:
>> clf
>> hold on
>> axis([-1 1 -1 1])
>> x=-1:0.0001:1;
>> y=cos(1/x)
>> plot(x,y)
May I know why I keep getting this error:-
(Error using / Matrix dimensions must agree...)?
1 件のコメント
guadalupe presa
2016 年 9 月 22 日
kEST=(s/(n+g+d))^(1/(1-alfa)); % realiza un código (k*)=steady state (NIVEL DE CAPITAL DE EQUILIBRIO)
SteadyState=findobj('Tag','STEADYSTATE'); set(SteadyState,'String',kEST);
upper=ceil(kEST)*2; jump=upper/10; k=(0:jump:upper)';
ec1=(n+g+d).*k; %ecuación 1= capital consumido: (n+g+d)*k (RECTA - FUNCION DE PRODUCCION) ec2=s.*k.^alfa; %ecuación 2= de capital acumulados:s*k^alfa (CURVA - FUNCION DE INVERSIÓN)
error: Error using / Matrix dimensions must agree.
Error in MODELOSOLOWCURVASFASE (line 87) kEST=(s/(n+g+d))^(1/(1-alfa)); % realiza un código (k*)=steady state (NIVEL DE CAPITAL DE EQUILIBRIO)
採用された回答
Amit Nambiar
2013 年 10 月 2 日
It should be like this: >> clf >> hold on >> axis([-1 1 -1 1]) >> x=-1:0.0001:1; >> y=cos(1./x) >> plot(x,y)
always use .* ./ (mul and div resp)for element by element operations. And use * / without "." for matrix operations.
0 件のコメント
その他の回答 (6 件)
Mugisha Aime
2017 年 9 月 21 日
Matrix dimensions must agree.
3 件のコメント
Image Analyst
2022 年 1 月 27 日
@Muhammad Azrul Izmee, it is right. Here's proof
x=-1:0.0001:1;
y=cos(1 ./ x)
plot(x, y, 'b-')
See? No error.
You should start a new question with your own code.
moahaimen talib
2017 年 3 月 20 日
hi please i need your help i need to process many images into wavelet function
yFolder = 'images';
if ~isdir(myFolder)
errorMessage = sprintf('Error: The following folder does not exist:\n%s', myFolder);
uiwait(warndlg(errorMessage));
return;
end
filePattern = fullfile(myFolder, '*.jpg');
jpegFiles = dir(filePattern);
for k = 1:length(jpegFiles)
baseFileName = jpegFiles(k).name;
fullFileName = fullfile(myFolder, baseFileName);
fprintf(1, 'Now reading %s\n', fullFileName);
imageArray = imread(fullFileName);
figure(k);imshow(imageArray); % Display image.
drawnow; % Force display to update immediately.
[coeffa,coeffh,coeffv,coeffd]=wavelet_process(imageArray);
i recieve this error
Error using + Matrix dimensions must agree.
Error in idwt2 (line 89) x = upsconv2(a,{Lo_R,Lo_R},sx,dwtEXTM,shift)+ ... % Approximation.
Error in wavelet_inv_process (line 5) resimg=idwt2(coeffa,coeffh,coeffv,coeffd,'haar');
Error in top_run2 (line 74) inv_wave_img=wavelet_inv_process(coeffa,imgadjh,imgadjv,imgadjd);
please SOS
0 件のコメント
ahmed reda
2019 年 7 月 3 日
編集済み: Image Analyst
2019 年 7 月 3 日
i want to know the error of this code iwant to plot w with X&Y and this error is founed
clear ;
clc;
close all;
R=0.01; %Shaft radius
m=1.675; %Disc mass (Kg)
L=0.5; %Shaft Length (m)
E=210*10^9; %Modulus of elasticity (N/m^2)
Ro=7850; %Density (Kg/m^3)
Ix=(1/4)*pi*R^4; %Moment of Inertia (Kg.m^2)
A=pi*R^2; %Cross section area (m^2)
K=48*E*Ix/L^3; %Shaft Stiffness simply supported (N/m)
Z=0.00125; %Damping ratio
C=Z*2*sqrt(K*m); %Damping constant (N/m)
e=0.059665; %eccentricity (m)
N=1500; %(rpm)
w=(0:.5:30); %rotational speed (rad/sec)
Wn=sqrt(K/m); % natural frequency
% h=0.001; %time step (sec)
g=9.81;
O=m*g/K; %Initial deflection
T=5;fs=5*8*w/(2*pi); dt=1/fs; %sampling frequency
tspan=(0:dt:T); %time interval
% X0 = [0 0]; %Initial displacement, Initial velocity in X direction
% Y0 = [O 0]; %Initial displacement, Initial velocity in y direction
% [~,X]=ode45(@abdo,tspan,X0,[],m,K,C,w,e);
% [t,Y]=ode45(@reda,tspan,Y0,[],m,K,C,w,e);
X=(m*e*(w*w))/sqrt((K-m*(w*w))^2+(C*w)^2);
Y=(m*e*(w*w))/sqrt((K-m*(w*w))^2+(C*w)^2);
plot(w,X);grid;xlabel('W(rad/sec)');ylabel('X');
figure
plot(w,Y);grid;xlabel('W(rad/sec)');ylabel('Y');
The error is:
Error using /
Matrix dimensions must agree.
Error in amplitudewithfrequency (line 21)
T=5;fs=5*8*w/(2*pi); dt=1/fs; %sampling frequency
5 件のコメント
Rafli Noorsyaif
2021 年 1 月 17 日
clc
clear all
close all
%Diketahui (E1,E2,G12 dalam satuan MPa)
E = 180000;
SIGMAY = 502;
%S,A,W dalam satuan m
S = 0.1;
a = 0.005;
W = 0.01:0.01:0.1;
K = ((3*(S/W)*sqrt(a/W))/(2*(1+2*(a/W))*((1-(a/W))^(3/2))))*(1.99-(a/W)*(1-(a/W)))*(2.15-3.93*(a/W)+2.7*((a/W)^(2)))
Displacement = (K^(2))/(E*SIGMAY)
I have the same problem (Matrix dimensions must agree) on the line 14
K = ((3*(S/W)*sqrt(a/W))/(2*(1+2*(a/W))*((1-(a/W))^(3/2))))*(1.99-(a/W)*(1-(a/W)))*(2.15-3.93*(a/W)+2.7*((a/W)^(2)))
Image Analyst
2021 年 1 月 17 日
Rafli, usually what many/most people do in situations like this, which have an incredibly complicated and involved equation, is to break it down into smaller parts, then examine the size of each term. Like
term1 = 3*S/W;
term2 = sqrt(a/W);
and so on. Just basic debugging technique.
Then make sure all your matrix multiplication dimensionss of each term make sense, and also make sure you really want to do a matrix multiplication with star and not an element-by-element multipliication with dot star.For example since you have term1*term2, that means the number of columns in term1 must equal the number of rows in term1 for a matrix multiplication since term1 is on the left side.
Start your own question if you still have trouble.
Rahayu A Halim
2021 年 8 月 8 日
Hello, please I need your help ![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/705902/image.gif)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/705902/image.gif)
my script:
%____________________________________________________________________
function fx=obj_pid_ga(x)
global Kp Ki Kd
%
%
Kp=x(1);Ki=x(2);Kd=x(3);
%
%____________________________________________________________________
[t,~,y]=sim('model_sistem_PID',0:0.05:10);
%____________________________________________________________________
%Integral of Squared Error
fx=sum(t.*abs(y).^2);
May I know why I keep getting this error:
Error using .*
Matrix dimensions must agree.
Error in obj_pid_ga (line 10)
fx=sum(t.*abs(y).^2);
0 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!