"Unable to perform assignment because the size of the left side is 1-by-1 and the size of the right side is 51-by-1" appears from A(N-1, N-2) = aw; How to solve this? Not sure what it says... Maybe someone can help me?
452 次查看(过去 30 天)
显示 更早的评论
%Data Given
N = 51;
mu = 0.1; %Pa
dt = 0.01; %delta time
dr = 0.0002; %radius between the points
rho = 1000; %kg/m3
k = [0,0.1,0.25,0.5,0.85]; %time
R = 0.01; %m
[r] = d_gridpoint(R);
%Constant Break Down
q = (mu*dt)/(rho*dr^2);
p = (mu*dt)./(2*rho*r*dr);
e = (2*mu*dt)/(rho*dr^2);
aw = (q)-(p);
ap = (-(e)-1);
ae = (q)+(p);
%Replace the Constant Into General Equation
%Apply Boundary Condition To Form a Matrix
%Initialization
A=zeros(N-1);
for i=2:N-2
A(i,i)=ap;
A(i,i-1)=aw(i);
A(i,i+1)=ae(i);
end
%Neumann Boundary Condition
A(1,1)=ap;
A(1,2)=(2*mu*dt)./(rho*dr.^2);
%Dirichlet Boundary Condition
A(N-1,N-1)=ap;
A(N-1,N-2)=aw;
0 个评论
采纳的回答
Walter Roberson
2018-3-24
We can tell from the line A(i,i-1)=aw(i); that aw is a vector of length at least N-2 . But in the line A(N-1,N-2)=aw you are attempting to assign that vector into the single location A(N-1,N-2)
0 个评论
更多回答(8 个)
prince kumar
2018-6-12
编辑:Walter Roberson
2018-6-12
clear ALL; clc;
%%INITIAL DATA
k=5;
% number of plate finite element
q=30; % kN/m2
f1=0; % kN
L= 6; % m all span
dhole=0;
h=0.010; % m
% L/125<=umax(h)<= L/500
E=210e6; % kpa
v=0.3;
r= L/2;
%radias of plate
rhole = dhole/2;
% radias of plate whole
l=(r-rhole)/k;
% length of one FE
%b=1/2 'half' of FE;
% 1=[0.2;1;0.6;0.6;0.6]
ro1FE= [0 0.10 0.20];
% coordinate of 1st FE
ro2FE= [0.20 0.70 1.20];
% coordinate of 2nd FE
ro3FE= [1.20 1.50 1.80];
% coordinate of 3rd FE
ro4FE= [1.80 2.10 2.40];
% coordinate of 4th FE
ro5FE= [2.40 2.70 3];
% coordinate of 5th FE
roFE= [ro1FE;ro2FE;ro3FE;ro4FE;ro5FE];
%%compatibility matrix of displacement
C=zeros(5*k,16);
C(1:6,1:5)=eye(5);
C(7:12,7:11)=eye(6);
C(13:18,13:17)=eye(6);
C(19:24,19:23)=eye(6,5);
% Coefficient matrix of equilibrium equation
for i=1:k
AK= zeros(6);
Ak(1,1) = roFE(i,1);
Ak(2,1)= 1.5*roFE(i,1)/b(i)-1; Ak(2,2)=1;
Ak(2,2) = 1;
Ak(2,3)=-2*roFE(i,1)/b(i);
Ak(2,5)=roFE(i,1)/(2*b(i));
Ak(3,1)= -roFE(i,2)/b(i)+2;
Ak(3,2)= -5/6;
Ak(3,3)= 2*roFE(i,2)/b(i)-2;
Ak(3,4)= 2/3;
Ak(3,5)= -roFE(i,2)/b(i);
Ak(3,6)= 1/6;
Ak(4,1)= -roFE(i,2)/b(i);
Ak(4,2)= -1/6;
Ak(4,3)= 2*roFE(i,2)/b(i)+2;
Ak(4,4)= -2/3;
Ak(4,5)= -roFE(i,2)/b(i)-2;
Ak(4,6)= 5/6;
Ak(5,5)= -roFE(i,3);
Ak(6,1)= roFE(i,3)/(2*b(i));
Ak(6,3)= -2*roFE(i,3)/b(i);
Ak(6,5)= 1+1.5*roFE(i,3)/b(i);
Ak(6,6)= -1;
Ak=2*pi*Ak;
% create diangonal matrix A
A(6*i-5:6*i,6*i-5:6*i)=Ak;
end
A=C' *A;
A;
% coefficient of flexibility matrix
for i=1:k
d11=4*roFE(i,2)-3*b(i);
d12=-v*(4*roFE(i,2)-3*b(i));
d13=2*(roFE(i,2)-b(i));
d14=-2*v(roFE(i,2)-b(i));
d15=-roFE(i,2);
d16=v*roFE(i,2);
d22=4*(roFE(i,2)-3*b(i));
d23=-2*v*(roFE(i,2)-b(i));
d24=-2*(roFE(i,2)-b(i));
d25=v*roFE(i,2);
d26=-roFE(i,2);
d33=16*roFE(i,2);
d34=-16*v*roFE(i,2);
d35=2*(roFE(i,2)+b(i));
d36=-2*v(roFE(i,2)+b(i));
d44=16*roFE(i,2);
d45=-2*v(roFE(i,2)+b(i));
d46=2*(roFE(i,2)+b(i));
d55=4*(roFE(i,2)+3*b(i));
d56=v*(4*roFE(i,2)+3*b(i));
d66=4*(roFE(i,2)+3*b(i));
Dk=((2*pi*b)/(15*kk*(1-v*v)))*Dk;
D(6*i-5:6*i,6*i-5:6*i)=Dk;
end
%%External load vector
% Distribution load vector
% {F}={Fo}+{Fp}={Fo}+[C]'*{Fp}
% create vertical matrix Fo
Fo=zeros(21,1);
Fo(1)=m1*2*pi*roFE(1,1);
Fo(2)=f1*2*pi*roFE(1,1);
Fo(18)=f2*2*pi*roFE(5,1);
Fo(21)=m2*2*pi*roFE(5,3);
q=[0;q;q;0;0];
for i=1:k
Fk=2*pi*b(i)*q(i)/3*[3*roFE(i,2)-b(i);
3*roFE(i,2)+b(i)];
Fkp=[0;0;Fk;0;0];
% create vertical matrix Fp
Fp_(6*i-5:6*i,1)=Fkp;
end
Fp=C'*Fp;
F = Fo+Fp;
sizeF=size(F);
size_ADF=[sizeA;sizeD;sizeF];
alfa=D^-1*A'*(A*D^-1*A')^-1;
beta=(A*D^-1*A')^-1;
M=alfa*F;
u=1e3*beta*F; % in mm
Mro=M(1:2:END);
Mfi=M(2:2:END);
un=u(1:4:END);
what is the issue here can anyone tell
error coming like
Unable to perform assignment because the size of the left side is 6-by-5 and the size of the right side is 5-by-5?
2 个评论
Stephen23
2018-6-12
"what is the issue here can anyone tell"
The error message tells you: you are trying to put 25 elements into 30 elements:
"Unable to perform assignment because the size of the left side is 6-by-5 and the size of the right side is 5-by-5"
Solution: don't try to put 25 elements into 30 elements.
Walter Roberson
2018-6-12
You have
C(1:6,1:5)=eye(5);
the left side is 6 x 5. The right side is 5 x 5.
Perhaps you want
C(1:5,1:5)=eye(5);
C(6,1:5) = 0;
muhammad choudhry
2019-11-13
编辑:Walter Roberson
2022-3-25
Unable to perform assignment because the size of the left side is 1-by-1 and the size of the right side is 2-by-1.
Error in crosscorrelation (line 53)
dpx(i,j) = xpeak1 - xgrid(i);
Does anyone know where I am goign wrong?
clear all;
clc;
close all;
%frame 1 and frame 2
imagea = imread('frame1.jpg');
imageb = imread('frame2.jpg');
[xmax,ymax]=size(imagea);
%windowsizes
wsize=[64,64];
w_width=wsize(1);
w_height=wsize(2);
%center points grid
xmin=w_width/2;
ymin=w_height/2;
xgrid=200:w_width/2:864;
ygrid=200:w_height/2:1696
%number of window in total
w_xcount = length (xgrid);
w_ycount = length (ygrid);
% these correspond to the range for "search" windows in image B
x_disp_max = w_width/2;
y_disp_max = w_height/2;
% for every window, first we have to "create" the test matrix in image A.
% then in image B, we have to correlate this test window around it's
% original position in A, the range is pre-determined. The point of maximum
% correlation corresponds to the final avg. displacement of that window
test_ima(w_width,w_height)=0;
test_imb(w_width+2*x_disp_max, w_height+2*y_disp_max) = 0;
dpx (w_xcount, w_ycount) = 0;
dpy (w_xcount, w_ycount) = 0;
xpeak1 = 0;
xpeak1 = 0;
%i, j are for the windows
%test_i and test_j are the test window to be
%extracted from image A
for i=1:(w_xcount)
for j=1:(w_ycount)
max_correlation = 0;
test_xmin = xgrid(i)-w_width/2;
test_xmax = xgrid(i)+w_width/2;
test_ymin = ygrid(j)-w_width/2;
test_ymax = ygrid(j)-w_width/2;
x_disp = 0;
y_disp = 0;
test_ima = imagea(test_xmin:test_xmax, test_ymin:test_ymax);
test_imb = imageb((test_xmin-x_disp_max):(test_xmax+x_disp_max),(test_ymin-y_disp_max):(test_ymax+y_disp_max));
correlation = normxcorr2(test_ima,test_imb);
[xpeak,ypeak] = find(correlation==max(correlation(:)));
%Re-scaling
xpeak1 = test_xmin + xpeak - wsize(1)/2 - x_disp_max;
ypeak1 = test_ymin + ypeak - wsize(2)/2 - y_disp_max;
dpx(i,j) = xpeak1 - xgrid(i);
dpy (i,j) = ypeak1 - ygrid(i);
end
end
%vector display
quiver (dpy,-dpx)
1 个评论
Nagvendra kumar kanoje
2022-12-4
Error is showing after running the code
Unable to perform assignment because the size of the left side is 257-by-1 and the size of the right side
is 257-by-257.
Error in STFT (line 45)
Spec(Index, iLoop) = Sig(iIndex1).* conj(WinFun(iIndex2));
Error in TEST1 (line 59)
[Spec,Freq] = STFT(Sig,fLevel,WinLen,Fs);
function [Spec,Freq] = STFT(Sig,fLevel,WinLen,SampFreq)
% Calculating the short-time Fourier transform of discrete signals
% --------------------INPUT------------------%
% Sig £ºOne-dimensional signal sequence to be analyzed
% fLevel£ºfrequency axis points associated with the Spec(in Bins)
% WinLen£ºGauss window width(in Bins)
% SampFreq£ºSignal sampling frequency(in Hz)
% --------------------OUTPUT------------------%
% Spec £º2D spectrum results (horizontal time axis, vertical frequency axis)
% Freq £ºvertical frequency axis(in Hz)
%--------------------------------------------------------%
% written by Guowei Tu, 28/07/2019 in SME,SJTU (Contact me via GuoweiTu@sjtu.edu.cn)
if (nargin < 1)
error('At least one parameter required!');
end
SigLen = length(Sig);
if (nargin < 4)
SampFreq = 50;
end
if (nargin < 3)
WinLen = 64;
end
if (nargin < 2)
fLevel = 512;
end
%--------------------------------------------------------%
fLevel = ceil(fLevel/2) * 2+1;
WinLen = ceil(WinLen/2) * 2+1;
%--------------------------------------------------------%
WinFun = exp(-6* linspace(-1,1,WinLen).^2);
%--------------------------------------------------------%
Lw = (WinLen - 1)/2;
Lf = (fLevel - 1)/2;
Spec = zeros(fLevel,SigLen);
%--------------------------------------------------------%
for iLoop = 1:SigLen;
iLeft = min([iLoop-1, Lw, Lf]);
iRight = min([SigLen-iLoop, Lw, Lf]);
iIndex = -iLeft:iRight;
iIndex1 = iIndex + iLoop;
iIndex2 = iIndex + Lw + 1;
Index = iIndex + Lf +1;
Spec(Index, iLoop) = Sig(iIndex1).* conj(WinFun(iIndex2));
end
%--------------------------------------------------------%
Spec = fft(Spec); % STFT
Spec = Spec*2/fLevel;
Spec = Spec(1:(end-1)/2,:);
fk = 0:1:fLevel-1;
fk = fk(1:(end-1)/2);
Freq = linspace(0,0.5*SampFreq,length(fk));
end
yusuf oyal
2021-1-11
编辑:Walter Roberson
2022-3-25
%CLEAR: Variables and command window in MATLAB
clc,clear
% INPUT: PHYSICAL PARAMETERS of MECHANISM (centemeter)
ab=24;bc=20;dc=15 ;bd=24;de=15;fl=17;fg=25;el=20;ag=40;
% INPUT: Maximum Iteration Number Nmax
Nmax=100;
% INPUT: INITIAL GUESS VALUES for th3 th4, th5, s and to respectively
x=[190*pi/180,110*pi/180,150*pi/180,31];
% INPUT: ERROR TOLERANCE
xe=0.001*abs(x);
% INPUT: SYSTEM INPUTS (th2,w2,al2)
dth=5*pi/360;
th2=(0*pi/180):dth:(360*pi/180);
w2=10*ones(1,length(th2));
al2=0*ones(1,length(th2));
%----------------------------------------------
xe=transpose(abs(xe));
kerr=1; %If kerr=1, results are not converged
%%
for k=1:1:length(th2)
for n=1:Nmax
%----------------------------------------------
%Assign initial guess to unknowns
th3(k)=x(1);th4(k)=x(2);th5(k)=x(3);s(k)=x(4);
% INPUT: JACOBIAN Matrix
J=zeros(4,4);
J(1,1)=-bc*sin(th3(k)); J(1,3)=-s*sin(th5(k)); J(1,4)=cos(th5(k));
J(2,1)=bc*cos(th3(k));J(2,3)=s*cos(th5(k));J(2,4)=sin(th5(k));
J(3,1)=dc*sin(th3(k)+(1.488));J(3,2)=-de*sin(th4(k));J(3,3)=-s*sin(th5(k));J(3,4)=cos(th5(k));
J(4,1)=-dc*cos(th3(k)+(1.488));J(4,2)=de*cos(th4(k));J(4,3)=s*cos(th5(k));J(4,4)=sin(th5(k));
% INPUT: Function f
f=zeros(4,1);
f(1,1)=-(-ab*cos(th2(k))+bc*cos(th3(k))+s*cos(th5(k))+ag);
f(2,1)=-(-ab*sin(th2(k))+bc*sin(th3(k))+s*sin(th5(k))-fg);
f(3,1)=-(de*cos(th4(k))-dc*cos(th3(k)+(1.488))+s*cos(th5(k))-el);
f(4,1)=-(de*sin(th4(k))-dc*sin(th3(k)+(1.488))+s*sin(th5(k))-fl);
%----------------------------------------------
eps=inv(J)*f;x=x+transpose(eps);
if abs(eps)<xe
kerr=0;break
end
end
if kerr==1
fprintf('error')
end
th3(k)=x(1);th4(k)=x(2);th5(k)=x(3);s(k)=x(4);
%---velocity---------------------------
fv(1,1)=-ab*w2(k)*sin(th2(k));
fv(2,1)=ab*w2(k)*cos(th2(k));
fv(3,1)=0;
fv(4,1)=0;
vel=inv(J)*fv;
w3(k)=vel(1);w4(k)=vel(2);w5(k)=vel(3);Vs(k)=vel(4);
%---acceleration---------------------------
fa(1,1)=(bd*al2(k)*cos(th2(k))+bd*w2(k)^2*cos(th2(k))-bc*w3(k)^2*cos(th3(k))-2*Vs*w5(k)*cos(th5(k))-s*w5(k)^2*cos(th5(k)));
fa(2,1)=(-bd*al2(k)*sin(th2(k))+bd*w2(k)^2*sin(th2(k))-bc*w3(k)^2*sin(th3(k))-2*Vs*w5(k)*sin(th5(k))-s*w5(k)^2*sin(th5(k)));
fa(3,1)=(-s*w5(k)^2*cos(th5(k))+dc*w3(k)^2*cos(th3(k))+(1.488))-de*w4(k)^2*cos(th4(k))-2*Vs*w5(k)*sin(th5(k));
fa(4,1)=(-s*w5(k)^2*sin(th5)+dc*w3(k)^2*sin(th3(k))+(1.488))-de*w4(k)^2*sin(th4(k))+2*Vs*w5(k)*cos(th5(k));
acc=inv(J)*fa;
al3(k)=acc(1);al4(k)=acc(2);
al5(k)=acc(3);als(k)=acc(4);
end
% Angle: radian --> degree
th2d=th2*180/pi;
th3d=th3*180/pi;
th4d=th4*180/pi;
th5d=th5*180/pi;
%--------Plots---------------
figure(1),
subplot(4,3,1),plot(th2d,th3d,'r','linewidth',2),xlabel('\theta_2 (^o)'),ylabel('\theta_3(^o)'),grid on;
subplot(4,3,2),plot(th2d,w3,'r','linewidth',2),xlabel('\theta_2 (^o)'),ylabel('\omega_3(r/s)'),grid on;
subplot(4,3,3),plot(th2d,al3,'r','linewidth',2),xlabel('\theta_2 (^o)'),ylabel('\alpha_3(r/s^2)'),grid on;
subplot(4,3,4),plot(th2d,th4d,'r','linewidth',2),xlabel('\theta_2(^o)'),ylabel('\theta_4 (^o)'),grid on;
subplot(4,3,5),plot(th2d,w4,'r','linewidth',2),xlabel('\theta_2(^o)'),ylabel('\omega_4 (r/s)'),grid on;
subplot(4,3,6),plot(th2d,al4,'r','linewidth',2),xlabel('\theta_2 (^o)'),ylabel('\alpha_4(r/s^2)'),grid on;
subplot(4,3,7),plot(th2d,th5d,'r','linewidth',2),xlabel('\theta_2 (^o)'),ylabel('\theta_5(^o)'),grid on;
subplot(4,3,8),plot(th2d,w5,'r','linewidth',2),xlabel('\theta_2 (^o)'),ylabel('\omega_5(r/s)'),grid on;
subplot(4,3,9),plot(th2d,al5,'r','linewidth',2),xlabel('\theta_2 (^o)'),ylabel('\alpha_5(r/s^2)'),grid on;
subplot(4,3,10),plot(th2d,s,'r','linewidth',2),xlabel('\theta_2 (^o)'),ylabel('\theta_6(^o)'),grid on;
subplot(4,3,11),plot(th2d,Vs,'r','linewidth',2),xlabel('\theta_2 (^o)'),ylabel('\omega_6(m/s)'),grid on;
subplot(4,3,12),plot(th2d,als,'r','linewidth',2),xlabel('\theta_2 (^o)'),ylabel('\alpha_6(m/s^2)'),grid on;
2 个评论
Walter Roberson
2021-1-11
th3(k)=x(1);th4(k)=x(2);th5(k)=x(3);s(k)=x(4);
s(k) is assigned to so s is a vector.
% INPUT: JACOBIAN Matrix
J=zeros(4,4);
J(1,1)=-bc*sin(th3(k)); J(1,3)=-s*sin(th5(k)); J(1,4)=cos(th5(k));
s is a vector so -s*sin(th5(k)) is a vector but the left side of the assignment J(1,3) only has room for a scalar.
image-pro
2021-10-20
编辑:Walter Roberson
2022-3-25
clc;
a=imread('C:/Users/DELL/Downloads/new-grayscale.jpg');
imshow(a);
[r,c]=size(a);
rs=input('No of row splitted');
cs=input('No of col splitted');
nr=floor(r/rs);
nc=floor(c/cs);
SA(rs,cs,nr*nc)=0;
z=1;
for i=1:nr
for j=1:nc
SA(:,:,z)=a(((i-1)*rs+1):rs*i,((j-1)*cs+1):cs*j);
z=z+1;
end
end
i want to split image in matrix but following error is showing please solve this problem.
Unable to perform assignment because the size of the left side is 50-by-50 and the size
of the right side is 2-by-2.
Error in p12 (line 15)
SA(:,:,z)=a(((i-1)*rs+1):rs*i,((j-1)*cs+1):cs*j);
1 个评论
Walter Roberson
2021-10-20
I think you had an existing SA variable that you did not clear.
Remember that if you use functions then existing variables in the base workspace cannot interfere.
kevin harianto
2022-3-25
编辑:Walter Roberson
2022-3-25
Unable to perform assignment because the size of the left side is 1856-by-3 and the size of the right
side is 1856-by-1. I want to use the lidar labeler app for reading through the code using the ROI labels
error in:
image(:,:,4) = ptcloud.Intensity;
I = helperPointCloudToImage(pointCloud);
from Playing around from the example using different dataSets with importing the data from the link: https://github.com/olpotkin/Lidar-Obstacle-Detection/tree/master/src/sensors/data/pcd/data_2
classdef LidarSemanticSegmentation < lidar.labeler.AutomationAlgorithm
% LidarSemanticSegmentation Automation algorithm performs semantic
% segmentation in the point cloud.
% LidarSemanticSegmentation is an automation algorithm for segmenting
% a point cloud using SqueezeSegV2 semantic segmentation network
% which is trained on Pandaset data set.
%
% See also lidarLabeler, groundTruthLabeler
% lidar.labeler.AutomationAlgorithm.
% Copyright 2021 The MathWorks, Inc.
% ----------------------------------------------------------------------
% Step 1: Define the required properties describing the algorithm. This
% includes Name, Description, and UserDirections.
properties(Constant)
% Name Algorithm Name
% Character vector specifying the name of the algorithm.
Name = 'Lidar Semantic Segmentation';
% Description Algorithm Description
% Character vector specifying the short description of the algorithm.
Description = 'Segment the point cloud using SqueezeSegV2 network.';
% UserDirections Algorithm Usage Directions
% Cell array of character vectors specifying directions for
% algorithm users to follow to use the algorithm.
UserDirections = {['ROI Label Definition Selection: select one of ' ...
'the ROI definitions to be labeled'], ...
'Run: Press RUN to run the automation algorithm. ', ...
['Review and Modify: Review automated labels over the interval ', ...
'using playback controls. Modify/delete/add ROIs that were not ' ...
'satisfactorily automated at this stage. If the results are ' ...
'satisfactory, click Accept to accept the automated labels.'], ...
['Accept/Cancel: If the results of automation are satisfactory, ' ...
'click Accept to accept all automated labels and return to ' ...
'manual labeling. If the results of automation are not ' ...
'satisfactory, click Cancel to return to manual labeling ' ...
'without saving the automated labels.']};
end
% ---------------------------------------------------------------------
% Step 2: Define properties you want to use during the algorithm
% execution.
properties
% AllCategories
% AllCategories holds the default 'unlabelled', 'Vegetation',
% 'Ground', 'Road', 'RoadMarkings', 'SideWalk', 'Car', 'Truck',
% 'OtherVehicle', 'Pedestrian', 'RoadBarriers', 'Signs',
% 'Buildings' categorical types.
AllCategories = {'unlabelled'};
% PretrainedNetwork
% PretrainedNetwork saves the pretrained SqueezeSegV2 network.
PretrainedNetwork
end
%----------------------------------------------------------------------
% Note: this method needs to be included for lidarLabeler app to
% recognize it as using pointcloud
methods (Static)
% This method is static to allow the apps to call it and check the
% signal type before instantiation. When users refresh the
% algorithm list, we can quickly check and discard algorithms for
% any signal that is not support in a given app.
function isValid = checkSignalType(signalType)
isValid = (signalType == vision.labeler.loading.SignalType.PointCloud);
end
end
%----------------------------------------------------------------------
% Step 3: Define methods used for setting up the algorithm.
methods
function isValid = checkLabelDefinition(algObj, labelDef)
% Only Voxel ROI label definitions are valid for the Lidar
% semantic segmentation algorithm.
isValid = labelDef.Type == lidarLabelType.Voxel;
if isValid
algObj.AllCategories{end+1} = labelDef.Name;
end
end
function isReady = checkSetup(algObj)
% Is there one selected ROI Label definition to automate.
isReady = ~isempty(algObj.SelectedLabelDefinitions);
end
end
%----------------------------------------------------------------------
% Step 4: Specify algorithm execution. This controls what happens when
% the user presses RUN. Algorithm execution proceeds by first
% executing initialize on the first frame, followed by run on
% every frame, and terminate on the last frame.
methods
function initialize(algObj,~)
% Load the pretrained SqueezeSegV2 semantic segmentation network.
outputFolder = fullfile(tempdir, 'Pandaset');
pretrainedSqueezeSeg = load(fullfile(outputFolder,'trainedSqueezeSegV2PandasetNet.mat'));
% Store the network in the 'PretrainedNetwork' property of this object.
algObj.PretrainedNetwork = pretrainedSqueezeSeg.net;
end
function autoLabels = run(algObj, pointCloud)
% Setup categorical matrix with categories including
% 'Vegetation', 'Ground', 'Road', 'RoadMarkings', 'SideWalk',
% 'Car', 'Truck', 'OtherVehicle', 'Pedestrian', 'RoadBarriers',
% and 'Signs'.
autoLabels = categorical(zeros(size(pointCloud.Location,1), size(pointCloud.Location,2)), ...
0:12,algObj.AllCategories);
% Convert the input point cloud to five channel image.
I = helperPointCloudToImage(pointCloud);
% Predict the segmentation result.
predictedResult = semanticseg(I, algObj.PretrainedNetwork);
autoLabels(:) = predictedResult;
%using this area we would be able to continuously update the latest file on
% sending the output towards the CAN Network or atleast ensure that the
% item is obtainable
% This area would work the best as it is the place where the
% lidar app will run every time.
%first we must
end
end
end
function image = helperPointCloudToImage(ptcloud)
% helperPointCloudToImage converts the point cloud to 5 channel image
image = ptcloud.Location;
image(:,:,4) = ptcloud.Intensity;
rangeData = iComputeRangeData(image(:,:,1),image(:,:,2),image(:,:,3));
image(:,:,5) = rangeData;
index = isnan(image);
image(index) = 0;
end
function rangeData = iComputeRangeData(xChannel,yChannel,zChannel)
rangeData = sqrt(xChannel.*xChannel+yChannel.*yChannel+zChannel.*zChannel);
end
4 个评论
kevin harianto
2022-3-25
编辑:kevin harianto
2022-3-25
It says
error at Index in position 3 exceeds array bounds. Index must not exceed 1.
rangeData = iComputeRangeData(image(:,:,1),image(:,:,2),image(:,:,3));
After removing the columns
to rangeData = iComputeRangeData(image(:,1),image(:,2),image(:,3));
there it says.
Error using semanticseg>iCheckImage
Input image size must be greater than [64 1856]. The minimum input image size must be equal to or greater than the input size in
image input layer of the network.
iCheckImage(I, netSize);
params = iParseInputs(I, net, varargin{:});
predictedResult = semanticseg(I, algObj.PretrainedNetwork);
videoLabels = run(this, frame);
Error in lidar.internal.lidarLabeler.tool.TemporalLabelingTool/runAlgorithm
Error in vision.internal.labeler.tool.AlgorithmTab/setAlgorithmModeAndExecute
Error in vision.internal.labeler.tool.AlgorithmTab
feval(callback, src, event);
internal.Callback.execute(this.PushPerformedFcn, this, eventdata);
Error in matlab.ui.internal.toolstrip.base.ActionInterface>@(event,data)PeerEventCallback(this,event,data) (line 57)
this.PeerEventListener = addlistener(this.Peer, 'peerEvent', @(event, data) PeerEventCallback(this, event, data));
feval(fcn{1},varargin{:},fcn{2:end});
hgfeval(response, java(o), e.JavaEvent)
Error in ()
@(o,e) cbBridge(o,e,response));
Behzad Ranjbar
2022-5-10
编辑:Walter Roberson
2022-5-10
for i=1,node_x;1;
if (DFlag_us==1)
F(1,i)=u_s/u_inf;
else
F(1,i)=-uf_s*dy+F(2,i);
end
if (DFlag_vs==1)
G(1,i)=v_s/u_inf;
else
G(1,i)=-vf_s*dy+G(2,i);
end
if (DFlag_un==1)
F(node_y-1,i)=u_n/u_inf;
else
F(node_y-1,i)=uf_n*dy+F(node_y-2,i);
end
if (DFlag_vn==1)
G(node_y-1,i)=v_n/u_inf;
else
G(node_y-1,i)=vf_n*dy+G(node_y-2,i);
end
end
for i=1,node_y;1;
if (DFlag_uw==1)
F(i,1)=u_w/u_inf;
else
F(i,1)=-uf_w*dx+F(i,2);
end
if (DFlag_vw==1)
G(i,1)=v_w/u_inf;
else
G(i,1)=-vf_w*dx+G(i,2);
end
if (DFlag_ue==1)
F(i,node_x-1)=u_e/u_inf;
else
F(i,node_x-1)=uf_e*dx+F(i,node_x-2);
end
if (DFlag_ve==1)
G(i,node_x-1)=v_e/u_inf;
else
G(i,node_x-1)=vf_e*dx+G(i,node_x-2);
end
end
for i=2,node_x-1;1;
DF(:,i)=(F(:,i)-F(:,i-1))/dx;
end
for j=2,node_y-1;1;
DG(j,:)=(G(j,:)-G(j-1,:))/dy;
end
I am recieving this error. (Unable to perform assignment because the size of the left side is 1-by-1 and the size of the right side is 99-by-1.
Error in Final (line 375)
DF(:,i)=(F(:,i)-F(:,i-1))/dx; )
Would you help me on this please!
3 个评论
Behzad Ranjbar
2022-5-10
thank you for your response, I corrected it still the same error.
Unable to perform assignment because the size of the left side is 1-by-1 and the size of the right side is 100-by-1.
Error in Final (line 375)
DF(:,i)=(F(:,i)-F(:,i-1))/dx;
Walter Roberson
2022-5-11
I suggest that you replace your calculation of DF and DG
DF = gradient(F, dx) ;
DG = gradient(G, dy) ;
Mustafa Batuhan Turaç
2022-5-19
Unable to perform assignment because the size of the left side is 1-by-600 and the size of the right side is 1-by-100.
%Plot P-V diagram of a given substance using van der Waals equation of states
%Substance properties are defined by the van der Waals constants and
%the critical properties.
clc; clear; close all;
Tc = 765.62; % R
Pc = 550.60; % psi
Vc = 4.086; % ft3/lbmole
R = 10.732; % psi ft3/(lbmole-R)
% van der Waals Equation of State Constants
% for Propane
a = 54565.6;
b = 1.9639;
V = linspace(b*1.2,40*Vc,100); % vector of volume
% temperature in F
T = [60 180 230 270 300 306];
T = T + 460; % temperature in R
H = [1.250 1.118 1.069 1.031 1.0049 0.999];
%van der Waals Equation
fvdWEOSp = @(Tx,Vx,Hx)(R*Tx./(Vx-b)-a*Hx./(Vx.^2 + 2*Vx*b-b^2));
P = zeros(numel(T), numel(V), numel(H));
for i= 1:numel(T)
Tx = T(i);
Hx = H(i);
P(i,:) = fvdWEOSp(Tx,V,Hx);
end
% plot(V,P); xlim([0 1000]);
semilogx(V,P); xlim([1 100]);
ylim([0 1000]);
xlim([0 200]);
xlabel('Volume, ft^3');
ylabel('Pressure, psi');
2 个评论
Walter Roberson
2022-5-19
P = zeros(numel(T), numel(V), numel(H));
3d array
P(i,:) = fvdWEOSp(Tx,V,Hx);
being assigned to with only two indices.
Tx = T(i); Hx = H(i);
if T and H are always indexed at the same index, then does it make sense to use a 3d array?
kim zheng cho
2022-12-3
编辑:Walter Roberson
2022-12-4
d = rng(211); % Set RNG state for repeatability
numFFT = 1024; % Number of FFT points
numGuards = 212; % Guard bands on both sides
K = 4; % Overlapping symbols, one of 2, 3, or 4
numSymbols = 100; % Simulation length in symbols
bitsPerSubCarrier = 6; % 2: 4QAM, 4: 16QAM, 6: 64QAM, 8: 256QAM
bitsinreceiver = 6;
snrdB = 15; % SNR in dB
% Prototype filter
switch K
case 2
HkOneSided = sqrt(2)/2;
case 3
HkOneSided = [0.911438 0.411438];
case 4
HkOneSided = [0.971960 sqrt(2)/2 0.235147];
otherwise
return
end
% Build symmetric filter
Hk = [fliplr(HkOneSided) 1 HkOneSided];
% Transmit-end processing
% Initialize arrays
L = numFFT-2*numGuards; % Number of complex symbols per OFDM symbol
KF = K*numFFT;
KL = K*L;
dataSubCar = zeros(L, 1);
dataSubCarUp = zeros(KL, 1);
sumFBMCSpec = zeros(KF*2, 1);
numBits = bitsPerSubCarrier*L/2; % account for oversampling by 2
inpData = zeros(numBits, numSymbols);
rxBits = zeros(numBits, numSymbols);
txSigAll = complex(zeros(KF, numSymbols));
symBuf = complex(zeros(2*KF, 1));
% Loop over symbols
for symIdx = 1:numSymbols
% Generate mapped symbol data
inpData(:, symIdx) = randi([0 1], numBits, 1);
modData = qammod(inpData(:, symIdx), 2^bitsPerSubCarrier, ...
'InputType', 'Bit', 'UnitAveragePower', true);
% OQAM Modulator: alternate real and imaginary parts
if rem(symIdx,2)==1 % Odd symbols
dataSubCar(1:2:L) = real(modData);
dataSubCar(2:2:L) = 1i*imag(modData);
else % Even symbols
dataSubCar(1:2:L) = 1i*imag(modData);
dataSubCar(2:2:L) = real(modData);
end
% Upsample by K, pad with guards, and filter with the prototype filter
dataSubCarUp(1:K:end) = dataSubCar;
dataBitsUpPad = [zeros(numGuards*K,1); dataSubCarUp; zeros(numGuards*K,1)];
X1 = filter(Hk, 1, dataBitsUpPad);
% Remove 1/2 filter length delay
X = [X1(K:end); zeros(K-1,1)];
% Compute IFFT of length KF for the transmitted symbol
txSymb = fftshift(ifft(X));
% Transmitted signal is a sum of the delayed real, imag symbols
symBuf = [symBuf(numFFT/2+1:end); complex(zeros(numFFT/2,1))];
symBuf(KF+(1:KF)) = symBuf(KF+(1:KF)) + txSymb;
% Store transmitted signals for all symbols
currSym = complex(symBuf(1:KF));
txSigAll(:,symIdx) = currSym;
txrealsignal=real(txSigAll);
tximgsignal=imag(txSigAll);
% real and imaginarysignal
A=(47.32*real(txSigAll(:,12)));
B=(47.32*real(txSigAll(:,13)));
C=[A B];
D=reshape(C,8192,1);
%plot(D);
end
signal = 'C:\Users\User\Desktop\excel\complex1.csv';
T =readmatrix(signal);
BER = comm.ErrorRate;
% Process symbol-wise
for symIdx = 1:numSymbols
rxSig = T;%%modify
% Add WGN
%rxNsig = awgn(rxSig, snrdB, 'measured');%%no need later
% Perform FFT
rxf = fft(fftshift(rxSig));
% Matched filtering with prototype filter
rxfmf = filter(Hk, 1, rxf);
% Remove K-1 delay elements
rxfmf = [rxfmf(K:end); zeros(K-1,1)];
% Remove guards
rxfmfg = rxfmf(numGuards*K+1:end-numGuards*K);
% OQAM post-processing
% Downsample by 2K, extract real and imaginary parts
if rem(symIdx, 2)
% Imaginary part is K samples after real one
r1 = real(rxfmfg(1:2*K:end));
r2 = imag(rxfmfg(K+1:2*K:end));
rcomb = complex(r1, r2);
else
% Real part is K samples after imaginary one
r1 = imag(rxfmfg(1:2*K:end));
r2 = real(rxfmfg(K+1:2*K:end));
rcomb = complex(r2, r1);
end
% Normalize by the upsampling factor
rcomb = (1/K)*rcomb;
% De-mapper: Perform hard decision
rxBits(:, symIdx) = qamdemod(rcomb, 2^bitsinreceiver, ...
'OutputType', 'bit', 'UnitAveragePower', true);
end
% Measure BER with appropriate delay
BER.ReceiveDelay = bitsinreceiver*KL;
ber = BER(inpData(:), rxBits(:));
% Display Bit error
disp(['FBMC Reception for K = ' num2str(K) ', BER = ' num2str(ber(1)) ...
' at SNR = ' num2str(snrdB) ' dB'])
% Restore RNG state
rng(d);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Unable to perform assignment because the size of the left side is 1800-by-1 and the size of the right side is 4872-by-1.
Error in FBMC_edi_2 (line 123)
rxBits(:, symIdx) = qamdemod(rcomb, 2^bitsinreceiver, ...
Can someone help me on this?
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!