Category: Matlab
Category Archives: Matlab
Maximum recursion limit of 500 reached. Use set(0,’RecursionLimit’,N) to change the limit. Be aware that exceeding your available stack space can crash MATLAB and/or your computer.
it’s fine working on another laptop but in my laptop will getting above error………? can any one solve this….?
clear all;
close all;
a=imread(‘indus.jpg’);
b=rgb2gray(a);
[m,n]=size(b);
r=im2double(b);
% r=im2bw(b,0.75);
% ^r=b;
out=r;
for i=2:m-1
for j=2:n-1
h=[1*r(i-1,j-1) 1*r(i-1,j) 1*r(i-1,j+1);…
1*r(i,j-1) 1*r(i,j) 1*r(i,j+1);…
1*r(i+1,j-1) 1*r(i+1,j) 1*r(i+1,j+1)];
out(i,j)=(median(median(h)));
end
end
r=out;
sobel=r;
for i=2:m-1
for j=2:n-1
h=[-1*r(i-1,j-1) 0*r(i-1,j) 1*r(i-1,j+1);…
-2*r(i,j-1) 0*r(i,j) 2*r(i,j+1);…
-1*r(i+1,j-1) 0*r(i+1,j) 1*r(i+1,j+1)];
sobel(i,j)=(mean(mean(h)));
end
end
sobel1=sobel;
for i=2:m-1
for j=2:n-1
h=[-1*sobel(i-1,j-1) -2*sobel(i-1,j) -1*sobel(i-1,j+1);…
0*sobel(i,j-1) 0*sobel(i,j) 0*sobel(i,j+1);…
1*sobel(i+1,j-1) 2*sobel(i+1,j) 1*sobel(i+1,j+1)];
sobel1(i,j)=(mean(mean(h)));
end
end
% a=min(r,sobel1);
% figure,imshow(a);
res=max(sobel1,r);
figure,imshow(res);
subplot(221);imshow(r,[]);
subplot(222);imshow(res,[]);
subplot(223);imshow(sobel,[]);
subplot(224);imshow(sobel1,[]);it’s fine working on another laptop but in my laptop will getting above error………? can any one solve this….?
clear all;
close all;
a=imread(‘indus.jpg’);
b=rgb2gray(a);
[m,n]=size(b);
r=im2double(b);
% r=im2bw(b,0.75);
% ^r=b;
out=r;
for i=2:m-1
for j=2:n-1
h=[1*r(i-1,j-1) 1*r(i-1,j) 1*r(i-1,j+1);…
1*r(i,j-1) 1*r(i,j) 1*r(i,j+1);…
1*r(i+1,j-1) 1*r(i+1,j) 1*r(i+1,j+1)];
out(i,j)=(median(median(h)));
end
end
r=out;
sobel=r;
for i=2:m-1
for j=2:n-1
h=[-1*r(i-1,j-1) 0*r(i-1,j) 1*r(i-1,j+1);…
-2*r(i,j-1) 0*r(i,j) 2*r(i,j+1);…
-1*r(i+1,j-1) 0*r(i+1,j) 1*r(i+1,j+1)];
sobel(i,j)=(mean(mean(h)));
end
end
sobel1=sobel;
for i=2:m-1
for j=2:n-1
h=[-1*sobel(i-1,j-1) -2*sobel(i-1,j) -1*sobel(i-1,j+1);…
0*sobel(i,j-1) 0*sobel(i,j) 0*sobel(i,j+1);…
1*sobel(i+1,j-1) 2*sobel(i+1,j) 1*sobel(i+1,j+1)];
sobel1(i,j)=(mean(mean(h)));
end
end
% a=min(r,sobel1);
% figure,imshow(a);
res=max(sobel1,r);
figure,imshow(res);
subplot(221);imshow(r,[]);
subplot(222);imshow(res,[]);
subplot(223);imshow(sobel,[]);
subplot(224);imshow(sobel1,[]); it’s fine working on another laptop but in my laptop will getting above error………? can any one solve this….?
clear all;
close all;
a=imread(‘indus.jpg’);
b=rgb2gray(a);
[m,n]=size(b);
r=im2double(b);
% r=im2bw(b,0.75);
% ^r=b;
out=r;
for i=2:m-1
for j=2:n-1
h=[1*r(i-1,j-1) 1*r(i-1,j) 1*r(i-1,j+1);…
1*r(i,j-1) 1*r(i,j) 1*r(i,j+1);…
1*r(i+1,j-1) 1*r(i+1,j) 1*r(i+1,j+1)];
out(i,j)=(median(median(h)));
end
end
r=out;
sobel=r;
for i=2:m-1
for j=2:n-1
h=[-1*r(i-1,j-1) 0*r(i-1,j) 1*r(i-1,j+1);…
-2*r(i,j-1) 0*r(i,j) 2*r(i,j+1);…
-1*r(i+1,j-1) 0*r(i+1,j) 1*r(i+1,j+1)];
sobel(i,j)=(mean(mean(h)));
end
end
sobel1=sobel;
for i=2:m-1
for j=2:n-1
h=[-1*sobel(i-1,j-1) -2*sobel(i-1,j) -1*sobel(i-1,j+1);…
0*sobel(i,j-1) 0*sobel(i,j) 0*sobel(i,j+1);…
1*sobel(i+1,j-1) 2*sobel(i+1,j) 1*sobel(i+1,j+1)];
sobel1(i,j)=(mean(mean(h)));
end
end
% a=min(r,sobel1);
% figure,imshow(a);
res=max(sobel1,r);
figure,imshow(res);
subplot(221);imshow(r,[]);
subplot(222);imshow(res,[]);
subplot(223);imshow(sobel,[]);
subplot(224);imshow(sobel1,[]); maximum recursion limit of 500 reached. use set(0, ‘recursionlimit’, n) MATLAB Answers — New Questions
How do I edit my system path in Windows?
How do I edit my system path in Windows?How do I edit my system path in Windows? How do I edit my system path in Windows? change, path, environment, variable MATLAB Answers — New Questions
How to convert the format of data from sequences to matrices when designing deep learning networks?
Hello,
After importing the network into DeepNetworkDesigner for analysis, I encountered the following problem: after being processed by selfattentionLayer, the data size format is 577 (S) x 577 (C) x 1 (B).
I want to convert it to a format similar to imageInputLayer, _ (S) x_ (S) x_ (C) x_ (B). How can I use MATLAB to implement it?
The code for the network is as follows:
patchSize = 16;
embeddingOutputSize = 768;
layer = patchEmbeddingLayer(patchSize,embeddingOutputSize)
net = dlnetwork;
inputSize = [384 384 3];
maxPosition = (inputSize(1)/patchSize)^2 + 1;
numHeads = 4;
numKeyChannels = 4*embeddingOutputSize;
numClasses = 1000;
layers = [
imageInputLayer(inputSize)
patchEmbeddingLayer(patchSize,embeddingOutputSize,Name="patch-emb")
embeddingConcatenationLayer(Name="emb-cat")
positionEmbeddingLayer(embeddingOutputSize,maxPosition,Name="pos-emb");
additionLayer(2,Name="add")
selfAttentionLayer(numHeads,numKeyChannels,AttentionMask="causal",OutputSize=maxPosition)
fullyConnectedLayer(numClasses)
softmaxLayer];
net = addLayers(net,layers);
net = connectLayers(net,"emb-cat","add/in2");Hello,
After importing the network into DeepNetworkDesigner for analysis, I encountered the following problem: after being processed by selfattentionLayer, the data size format is 577 (S) x 577 (C) x 1 (B).
I want to convert it to a format similar to imageInputLayer, _ (S) x_ (S) x_ (C) x_ (B). How can I use MATLAB to implement it?
The code for the network is as follows:
patchSize = 16;
embeddingOutputSize = 768;
layer = patchEmbeddingLayer(patchSize,embeddingOutputSize)
net = dlnetwork;
inputSize = [384 384 3];
maxPosition = (inputSize(1)/patchSize)^2 + 1;
numHeads = 4;
numKeyChannels = 4*embeddingOutputSize;
numClasses = 1000;
layers = [
imageInputLayer(inputSize)
patchEmbeddingLayer(patchSize,embeddingOutputSize,Name="patch-emb")
embeddingConcatenationLayer(Name="emb-cat")
positionEmbeddingLayer(embeddingOutputSize,maxPosition,Name="pos-emb");
additionLayer(2,Name="add")
selfAttentionLayer(numHeads,numKeyChannels,AttentionMask="causal",OutputSize=maxPosition)
fullyConnectedLayer(numClasses)
softmaxLayer];
net = addLayers(net,layers);
net = connectLayers(net,"emb-cat","add/in2"); Hello,
After importing the network into DeepNetworkDesigner for analysis, I encountered the following problem: after being processed by selfattentionLayer, the data size format is 577 (S) x 577 (C) x 1 (B).
I want to convert it to a format similar to imageInputLayer, _ (S) x_ (S) x_ (C) x_ (B). How can I use MATLAB to implement it?
The code for the network is as follows:
patchSize = 16;
embeddingOutputSize = 768;
layer = patchEmbeddingLayer(patchSize,embeddingOutputSize)
net = dlnetwork;
inputSize = [384 384 3];
maxPosition = (inputSize(1)/patchSize)^2 + 1;
numHeads = 4;
numKeyChannels = 4*embeddingOutputSize;
numClasses = 1000;
layers = [
imageInputLayer(inputSize)
patchEmbeddingLayer(patchSize,embeddingOutputSize,Name="patch-emb")
embeddingConcatenationLayer(Name="emb-cat")
positionEmbeddingLayer(embeddingOutputSize,maxPosition,Name="pos-emb");
additionLayer(2,Name="add")
selfAttentionLayer(numHeads,numKeyChannels,AttentionMask="causal",OutputSize=maxPosition)
fullyConnectedLayer(numClasses)
softmaxLayer];
net = addLayers(net,layers);
net = connectLayers(net,"emb-cat","add/in2"); deep learning MATLAB Answers — New Questions
hello, I want to convert this code into legendre differential equation, can someone help?
clc
clear all
syms x z rhs rhs2 t x1 z2 y k4 k5
%%%euler legender starts
f=input (‘enter the function f(x), which is coefficient of D terms:’);
z2=log(f);
a=diff(f,x)
a
k1=input(‘enter the constant k1’);
k2=input(‘enter the constant k2’);
k3=input(‘enter constant k3’);
rhs=input (‘enter the rhs function, which is coefficient of D terms:’);
eqn=f==exp(z);
x=solve(eqn,x);
x
rhs2=subs(rhs,x)
rhs2
a0=k1*a^2;
b0=(k2*a)-(k1*a*a)
c0=k3
a1=a0/a0;b1=b0/a0;c1=c0/a0;
eq=a1*x1^2+b1*x1+c1
r=solve(eq,’x1′)
if imag(r)~=0
y1=exp(real(r(1))*z)*cos(imag(r(1))*z);
y2=exp(real(r(1))*z)*sin(abs(imag(r(1)))*z)
else if r(1)==r(2)
y1=exp(r(1)*z)
y2=z*exp(r(1)*z)
else
y1=exp(r(1)*z);
y2=exp(r(2)*z)
end
end
y_h=k4*y1+k5*y2;
W=simplify(y1*diff(y2)-y2*diff(y1));
g=rhs2;
y_p=-y1*int(y2*g/W)+y2*int(y1*g/W);
y=simplify(y_h+y_p);
y
simplify(subs(y,z,log(f)))clc
clear all
syms x z rhs rhs2 t x1 z2 y k4 k5
%%%euler legender starts
f=input (‘enter the function f(x), which is coefficient of D terms:’);
z2=log(f);
a=diff(f,x)
a
k1=input(‘enter the constant k1’);
k2=input(‘enter the constant k2’);
k3=input(‘enter constant k3’);
rhs=input (‘enter the rhs function, which is coefficient of D terms:’);
eqn=f==exp(z);
x=solve(eqn,x);
x
rhs2=subs(rhs,x)
rhs2
a0=k1*a^2;
b0=(k2*a)-(k1*a*a)
c0=k3
a1=a0/a0;b1=b0/a0;c1=c0/a0;
eq=a1*x1^2+b1*x1+c1
r=solve(eq,’x1′)
if imag(r)~=0
y1=exp(real(r(1))*z)*cos(imag(r(1))*z);
y2=exp(real(r(1))*z)*sin(abs(imag(r(1)))*z)
else if r(1)==r(2)
y1=exp(r(1)*z)
y2=z*exp(r(1)*z)
else
y1=exp(r(1)*z);
y2=exp(r(2)*z)
end
end
y_h=k4*y1+k5*y2;
W=simplify(y1*diff(y2)-y2*diff(y1));
g=rhs2;
y_p=-y1*int(y2*g/W)+y2*int(y1*g/W);
y=simplify(y_h+y_p);
y
simplify(subs(y,z,log(f))) clc
clear all
syms x z rhs rhs2 t x1 z2 y k4 k5
%%%euler legender starts
f=input (‘enter the function f(x), which is coefficient of D terms:’);
z2=log(f);
a=diff(f,x)
a
k1=input(‘enter the constant k1’);
k2=input(‘enter the constant k2’);
k3=input(‘enter constant k3’);
rhs=input (‘enter the rhs function, which is coefficient of D terms:’);
eqn=f==exp(z);
x=solve(eqn,x);
x
rhs2=subs(rhs,x)
rhs2
a0=k1*a^2;
b0=(k2*a)-(k1*a*a)
c0=k3
a1=a0/a0;b1=b0/a0;c1=c0/a0;
eq=a1*x1^2+b1*x1+c1
r=solve(eq,’x1′)
if imag(r)~=0
y1=exp(real(r(1))*z)*cos(imag(r(1))*z);
y2=exp(real(r(1))*z)*sin(abs(imag(r(1)))*z)
else if r(1)==r(2)
y1=exp(r(1)*z)
y2=z*exp(r(1)*z)
else
y1=exp(r(1)*z);
y2=exp(r(2)*z)
end
end
y_h=k4*y1+k5*y2;
W=simplify(y1*diff(y2)-y2*diff(y1));
g=rhs2;
y_p=-y1*int(y2*g/W)+y2*int(y1*g/W);
y=simplify(y_h+y_p);
y
simplify(subs(y,z,log(f))) #matlab #lengendre_differential_equation MATLAB Answers — New Questions
MATLAB installation error on linux PC
I’m trying to install MATLAB 2024a on my linuw PC (ubuntu version 20.04.6) as root. I followed the instrutions for linux OS that are provided on the MATLAB website. However I’m getting the following error
munmap_chunk(): invalid pointer
AbortedI’m trying to install MATLAB 2024a on my linuw PC (ubuntu version 20.04.6) as root. I followed the instrutions for linux OS that are provided on the MATLAB website. However I’m getting the following error
munmap_chunk(): invalid pointer
Aborted I’m trying to install MATLAB 2024a on my linuw PC (ubuntu version 20.04.6) as root. I followed the instrutions for linux OS that are provided on the MATLAB website. However I’m getting the following error
munmap_chunk(): invalid pointer
Aborted installation, error, linux MATLAB Answers — New Questions
hyperpca applied to a set of several hyperspectral images
I am trying to perform the PCA of several hyperspectral images.
I want to make one PCA with the entire set of images, not one PCA per image. To do this I run into several problems.
The first problem is that the data takes up a large amount of memory and the hyperpca function does not accept using tall arrays. Matlab’s PCA function does allow me to work with tall arrays but I don’t know how to perform a PCA for a three-dimensional array.
The second is that if I have to carry out the PCA of each of the images individually, how can I combine the PCAs?
If anyone can give me a hand I would appreciate it.I am trying to perform the PCA of several hyperspectral images.
I want to make one PCA with the entire set of images, not one PCA per image. To do this I run into several problems.
The first problem is that the data takes up a large amount of memory and the hyperpca function does not accept using tall arrays. Matlab’s PCA function does allow me to work with tall arrays but I don’t know how to perform a PCA for a three-dimensional array.
The second is that if I have to carry out the PCA of each of the images individually, how can I combine the PCAs?
If anyone can give me a hand I would appreciate it. I am trying to perform the PCA of several hyperspectral images.
I want to make one PCA with the entire set of images, not one PCA per image. To do this I run into several problems.
The first problem is that the data takes up a large amount of memory and the hyperpca function does not accept using tall arrays. Matlab’s PCA function does allow me to work with tall arrays but I don’t know how to perform a PCA for a three-dimensional array.
The second is that if I have to carry out the PCA of each of the images individually, how can I combine the PCAs?
If anyone can give me a hand I would appreciate it. hyperpca MATLAB Answers — New Questions
Error when using (self created) library block in a model
I have created a block in a library.
This block works (correct / expected behavior) when I try it in library directly.
But when I import the block in a model, I got error: parameter callback errors.
The block behavior is to modify its content (remove or add block inside) according to parameter values.
It can works in model if i cut the link to the library, but after I got lot of warning from advisor …I have created a block in a library.
This block works (correct / expected behavior) when I try it in library directly.
But when I import the block in a model, I got error: parameter callback errors.
The block behavior is to modify its content (remove or add block inside) according to parameter values.
It can works in model if i cut the link to the library, but after I got lot of warning from advisor … I have created a block in a library.
This block works (correct / expected behavior) when I try it in library directly.
But when I import the block in a model, I got error: parameter callback errors.
The block behavior is to modify its content (remove or add block inside) according to parameter values.
It can works in model if i cut the link to the library, but after I got lot of warning from advisor … library, block, callback MATLAB Answers — New Questions
R2023a for MacBook m1 sonoma 14.5 is crash
matlab r2023a is crash in my macbook air m1,my system version is sonoma14.5,but is amazing if i don’t close the window of crashreporter,the app is still runningmatlab r2023a is crash in my macbook air m1,my system version is sonoma14.5,but is amazing if i don’t close the window of crashreporter,the app is still running matlab r2023a is crash in my macbook air m1,my system version is sonoma14.5,but is amazing if i don’t close the window of crashreporter,the app is still running crash matlab macbook sonoma MATLAB Answers — New Questions
Find the linear Equation at different conditions – Machine Learning
I have a table of data that looks like this:
All data in the image are given here:
At different flowrate, there is a unique linear equation. What I want is to input the flowrate (for example, at 6.45 standard L/min), and get a linear equation at this flowrate.
Which maths/machine learning tool should I use, please? Thanks in advanceI have a table of data that looks like this:
All data in the image are given here:
At different flowrate, there is a unique linear equation. What I want is to input the flowrate (for example, at 6.45 standard L/min), and get a linear equation at this flowrate.
Which maths/machine learning tool should I use, please? Thanks in advance I have a table of data that looks like this:
All data in the image are given here:
At different flowrate, there is a unique linear equation. What I want is to input the flowrate (for example, at 6.45 standard L/min), and get a linear equation at this flowrate.
Which maths/machine learning tool should I use, please? Thanks in advance machine learning MATLAB Answers — New Questions
dsp.UDPReceiver shuts down MatLab
Hi
My MatLab (2019b) crashes when trying run the following lines:
hudpr = dsp.UDPReceiver(‘LocalIPPort’, 5010);
dataReceived= step(hudpr);
However, it runs without crashing in MatLab2013a.
Any suggestion to why it crashes?
Thanks
MarkusHi
My MatLab (2019b) crashes when trying run the following lines:
hudpr = dsp.UDPReceiver(‘LocalIPPort’, 5010);
dataReceived= step(hudpr);
However, it runs without crashing in MatLab2013a.
Any suggestion to why it crashes?
Thanks
Markus Hi
My MatLab (2019b) crashes when trying run the following lines:
hudpr = dsp.UDPReceiver(‘LocalIPPort’, 5010);
dataReceived= step(hudpr);
However, it runs without crashing in MatLab2013a.
Any suggestion to why it crashes?
Thanks
Markus udp MATLAB Answers — New Questions
Unable to import camera parameters or intrinsics to Simulink simulation
Hi, I have a CameraParameters struct in my workspace, but I am unable to import it into Simulink to use with AprilTag identification and similar. I have tried using the constant block, or the "From Workspace" block but neither is able to compile if I set the value to CameraParams, or CameraParams.Intrinsics (CameraParams is just the variable I have defined). Any help would be hugely appreciated.
Thank you!
The error using a From Workspace block is this:
Unsupported input format for From Workspace block ‘SimulinkEnv/From Workspace’. Input data must use a supported format such as timeseries or timetable and must not contain Inf or NaN values.
The error using a constant is this:
Invalid setting in ‘SimulinkEnv/Constant3’ for parameter ‘Value’Hi, I have a CameraParameters struct in my workspace, but I am unable to import it into Simulink to use with AprilTag identification and similar. I have tried using the constant block, or the "From Workspace" block but neither is able to compile if I set the value to CameraParams, or CameraParams.Intrinsics (CameraParams is just the variable I have defined). Any help would be hugely appreciated.
Thank you!
The error using a From Workspace block is this:
Unsupported input format for From Workspace block ‘SimulinkEnv/From Workspace’. Input data must use a supported format such as timeseries or timetable and must not contain Inf or NaN values.
The error using a constant is this:
Invalid setting in ‘SimulinkEnv/Constant3’ for parameter ‘Value’ Hi, I have a CameraParameters struct in my workspace, but I am unable to import it into Simulink to use with AprilTag identification and similar. I have tried using the constant block, or the "From Workspace" block but neither is able to compile if I set the value to CameraParams, or CameraParams.Intrinsics (CameraParams is just the variable I have defined). Any help would be hugely appreciated.
Thank you!
The error using a From Workspace block is this:
Unsupported input format for From Workspace block ‘SimulinkEnv/From Workspace’. Input data must use a supported format such as timeseries or timetable and must not contain Inf or NaN values.
The error using a constant is this:
Invalid setting in ‘SimulinkEnv/Constant3’ for parameter ‘Value’ simulink, computer vision, april tag, camera MATLAB Answers — New Questions
Use of Fmincon for stress relax data
I have to use "fmincon" to solve the optimization problem for the fitting of an "Stress Relaxation" curve. My aim is to define the coefficient of the Prony Series (gamma_i & tau_i).
The problem is that i don’t know how to define my function and start the fitting in order to find e1,e2,e3 & tau1,tau2,tau3.
In Input i have the experimental data (stress relax) and time
fun= E0 * (1 – ( (e1*(1-exp(-t/tau1))) + (e2*(1-exp(-t/tau2))) + (e3*(1-exp(-t/tau3)))))I have to use "fmincon" to solve the optimization problem for the fitting of an "Stress Relaxation" curve. My aim is to define the coefficient of the Prony Series (gamma_i & tau_i).
The problem is that i don’t know how to define my function and start the fitting in order to find e1,e2,e3 & tau1,tau2,tau3.
In Input i have the experimental data (stress relax) and time
fun= E0 * (1 – ( (e1*(1-exp(-t/tau1))) + (e2*(1-exp(-t/tau2))) + (e3*(1-exp(-t/tau3))))) I have to use "fmincon" to solve the optimization problem for the fitting of an "Stress Relaxation" curve. My aim is to define the coefficient of the Prony Series (gamma_i & tau_i).
The problem is that i don’t know how to define my function and start the fitting in order to find e1,e2,e3 & tau1,tau2,tau3.
In Input i have the experimental data (stress relax) and time
fun= E0 * (1 – ( (e1*(1-exp(-t/tau1))) + (e2*(1-exp(-t/tau2))) + (e3*(1-exp(-t/tau3))))) fmincon, optimization, prony MATLAB Answers — New Questions
Visually similar pcbstack objects resulting in different S parameter responses
Hi Mathworks community,
For the last couple of days I have been playing around with the antenna toolbox. I ran into a strange phenomenon when calculating the S parameters for an antenna configuration.
In my simulation, I am trying to take an antenna design and change the top layer to a parameterized version so that I can optimize the shape of the antenna. I added the pcbStack object describing the original antenna design in the attachment. The following code shows the steps I take to replace the top layer with the parameterized version:
clear all
close all
clc
% load the original antenna design
load("simplified_antenna.mat")
p.FeedViaModel = "octagon";
antenna_0 = p;
% define the parameterized version of the top layer
start = [7.74,8.73]*10^-3;
a = 0.999*10^-3;
b = 2.53*10^-3;
c = 4.1*10^-3;
d = 3.13*10^-3;
e = 1.4*10^-3;
f = 6*10^-3;
g = 1.3*10^-3;
h = 0.5*10^-3;
R = 0.35*10^-3;
ant1 = antenna.Rectangle( Length=g+h,Width=a, center=start+[-(g+h)/2,+a/2]);
ant2 = antenna.Rectangle( Length=h,Width=f+a, center=start+[-g-h/2,(a+f)/2]);
ant3 = antenna.Rectangle( Length=e,Width=a, center=start+[-g-h-e/2,a/2]);
ant4 = antenna.Rectangle( Length=c,Width=a, center=start+[-g-h-e-c/2,a/2]);
ant5 = antenna.Rectangle( Length=a,Width=b, center=start+[-g-h-e-c+a/2,b/2]);
ant6 = antenna.Rectangle( Length=c,Width=a, center=start+[-g-h-e-c/2,b-a/2]);
ant7 = antenna.Rectangle( Length=a,Width=b, center=start+[-g-h-e-a/2,b-a+b/2]);
ant8 = antenna.Rectangle( Length=c,Width=a, center=start+[-g-h-e-c/2,b+b-a*1.5]);
ant9 = antenna.Rectangle( Length=a,Width=b, center=start+[-g-h-e-c+a/2,b+b-a-a+b/2]);
ant10 = antenna.Rectangle( Length=c,Width=a, center=start+[-g-h-e-c/2,b+b+b-a*2.5]);
ant11 = antenna.Rectangle( Length=a,Width=b, center=start+[-g-h-e-a/2,b+b+b-a-a-a+b/2]);
ant12 = antenna.Rectangle( Length=c,Width=a, center=start+[-g-h-e-c/2,b+b+b+b-a*3.5]);
ant13 = antenna.Rectangle( Length=a,Width=d, center=start+[-g-h-e-c+a/2,b+b+b+b-a-a-a-a+d/2]);
ant14 = antenna.Circle(center=start+[-g-h/2,f+a], Radius=R);
Newobj = ant1+ant2+ant3+ant4+ant5+ant6+ant7+ant8+ant9+ant10+ant11+ant12+ant13+ant14;
% check if the parameterized and original version are the same:
figure
show(p.Layers{1,2})
title("Original top layer")
figure
show(Newobj)
title("Parameterized top layer")
% calculate the S parameters
spar_0 = sparameters(antenna_0, (2:0.1:4)*10^9);
figure
rfplot(spar_0);
title("S parameter original design")
antenna_1 = antenna_0;
antenna_1.Layers{1,2}.Vertices = Newobj.Vertices;
spar_1 = sparameters(antenna_1, (2:0.1:4)*10^9);
figure
rfplot(spar_1);
title("S parameter parameterized version 1")
antenna_2 = antenna_0;
antenna_2.Layers{1,2} = Newobj;
spar_2 = sparameters(antenna_2, (2:0.1:4)*10^9);
figure
rfplot(spar_2);
title("S parameter parameterized version 2")
To make sure that the parameterization is correct, I take two steps. First I check if the original and paramterized version look the same. The result is as follows and shows a nearly similar polygon:
After this, I calculate the S parameters of the resulting antenna design. This is where the strange phenomenon occurs. As the code shows, I add the parameterized top layer to the antenna design in two different ways: antenna_1.Layers{1,2}.Vertices = Newobj.Vertices; and antenna_2.Layers{1,2} = Newobj;. The resulting pcbStack objects are identical but give a significantly different simulation result as shown below:
My question is: How can these two simulations (version 1 and version 2) be significantly different even though the pcbStack objects corresponding to these two simulations are identical. On top of this, how do I know which of the two is the correct simulation. Am I missing a crucial difference between the two antennas designs?
My guess is that something is wrong with antenna design version 2 since the S parameter behaviour differs so much from the original antenna design’s S parameter behaviour. It is very unlikely that this huge difference is caused by the minimal difference between the original toplayer and parameterized top layer definitions.
Best regards,
Richard EveleensHi Mathworks community,
For the last couple of days I have been playing around with the antenna toolbox. I ran into a strange phenomenon when calculating the S parameters for an antenna configuration.
In my simulation, I am trying to take an antenna design and change the top layer to a parameterized version so that I can optimize the shape of the antenna. I added the pcbStack object describing the original antenna design in the attachment. The following code shows the steps I take to replace the top layer with the parameterized version:
clear all
close all
clc
% load the original antenna design
load("simplified_antenna.mat")
p.FeedViaModel = "octagon";
antenna_0 = p;
% define the parameterized version of the top layer
start = [7.74,8.73]*10^-3;
a = 0.999*10^-3;
b = 2.53*10^-3;
c = 4.1*10^-3;
d = 3.13*10^-3;
e = 1.4*10^-3;
f = 6*10^-3;
g = 1.3*10^-3;
h = 0.5*10^-3;
R = 0.35*10^-3;
ant1 = antenna.Rectangle( Length=g+h,Width=a, center=start+[-(g+h)/2,+a/2]);
ant2 = antenna.Rectangle( Length=h,Width=f+a, center=start+[-g-h/2,(a+f)/2]);
ant3 = antenna.Rectangle( Length=e,Width=a, center=start+[-g-h-e/2,a/2]);
ant4 = antenna.Rectangle( Length=c,Width=a, center=start+[-g-h-e-c/2,a/2]);
ant5 = antenna.Rectangle( Length=a,Width=b, center=start+[-g-h-e-c+a/2,b/2]);
ant6 = antenna.Rectangle( Length=c,Width=a, center=start+[-g-h-e-c/2,b-a/2]);
ant7 = antenna.Rectangle( Length=a,Width=b, center=start+[-g-h-e-a/2,b-a+b/2]);
ant8 = antenna.Rectangle( Length=c,Width=a, center=start+[-g-h-e-c/2,b+b-a*1.5]);
ant9 = antenna.Rectangle( Length=a,Width=b, center=start+[-g-h-e-c+a/2,b+b-a-a+b/2]);
ant10 = antenna.Rectangle( Length=c,Width=a, center=start+[-g-h-e-c/2,b+b+b-a*2.5]);
ant11 = antenna.Rectangle( Length=a,Width=b, center=start+[-g-h-e-a/2,b+b+b-a-a-a+b/2]);
ant12 = antenna.Rectangle( Length=c,Width=a, center=start+[-g-h-e-c/2,b+b+b+b-a*3.5]);
ant13 = antenna.Rectangle( Length=a,Width=d, center=start+[-g-h-e-c+a/2,b+b+b+b-a-a-a-a+d/2]);
ant14 = antenna.Circle(center=start+[-g-h/2,f+a], Radius=R);
Newobj = ant1+ant2+ant3+ant4+ant5+ant6+ant7+ant8+ant9+ant10+ant11+ant12+ant13+ant14;
% check if the parameterized and original version are the same:
figure
show(p.Layers{1,2})
title("Original top layer")
figure
show(Newobj)
title("Parameterized top layer")
% calculate the S parameters
spar_0 = sparameters(antenna_0, (2:0.1:4)*10^9);
figure
rfplot(spar_0);
title("S parameter original design")
antenna_1 = antenna_0;
antenna_1.Layers{1,2}.Vertices = Newobj.Vertices;
spar_1 = sparameters(antenna_1, (2:0.1:4)*10^9);
figure
rfplot(spar_1);
title("S parameter parameterized version 1")
antenna_2 = antenna_0;
antenna_2.Layers{1,2} = Newobj;
spar_2 = sparameters(antenna_2, (2:0.1:4)*10^9);
figure
rfplot(spar_2);
title("S parameter parameterized version 2")
To make sure that the parameterization is correct, I take two steps. First I check if the original and paramterized version look the same. The result is as follows and shows a nearly similar polygon:
After this, I calculate the S parameters of the resulting antenna design. This is where the strange phenomenon occurs. As the code shows, I add the parameterized top layer to the antenna design in two different ways: antenna_1.Layers{1,2}.Vertices = Newobj.Vertices; and antenna_2.Layers{1,2} = Newobj;. The resulting pcbStack objects are identical but give a significantly different simulation result as shown below:
My question is: How can these two simulations (version 1 and version 2) be significantly different even though the pcbStack objects corresponding to these two simulations are identical. On top of this, how do I know which of the two is the correct simulation. Am I missing a crucial difference between the two antennas designs?
My guess is that something is wrong with antenna design version 2 since the S parameter behaviour differs so much from the original antenna design’s S parameter behaviour. It is very unlikely that this huge difference is caused by the minimal difference between the original toplayer and parameterized top layer definitions.
Best regards,
Richard Eveleens Hi Mathworks community,
For the last couple of days I have been playing around with the antenna toolbox. I ran into a strange phenomenon when calculating the S parameters for an antenna configuration.
In my simulation, I am trying to take an antenna design and change the top layer to a parameterized version so that I can optimize the shape of the antenna. I added the pcbStack object describing the original antenna design in the attachment. The following code shows the steps I take to replace the top layer with the parameterized version:
clear all
close all
clc
% load the original antenna design
load("simplified_antenna.mat")
p.FeedViaModel = "octagon";
antenna_0 = p;
% define the parameterized version of the top layer
start = [7.74,8.73]*10^-3;
a = 0.999*10^-3;
b = 2.53*10^-3;
c = 4.1*10^-3;
d = 3.13*10^-3;
e = 1.4*10^-3;
f = 6*10^-3;
g = 1.3*10^-3;
h = 0.5*10^-3;
R = 0.35*10^-3;
ant1 = antenna.Rectangle( Length=g+h,Width=a, center=start+[-(g+h)/2,+a/2]);
ant2 = antenna.Rectangle( Length=h,Width=f+a, center=start+[-g-h/2,(a+f)/2]);
ant3 = antenna.Rectangle( Length=e,Width=a, center=start+[-g-h-e/2,a/2]);
ant4 = antenna.Rectangle( Length=c,Width=a, center=start+[-g-h-e-c/2,a/2]);
ant5 = antenna.Rectangle( Length=a,Width=b, center=start+[-g-h-e-c+a/2,b/2]);
ant6 = antenna.Rectangle( Length=c,Width=a, center=start+[-g-h-e-c/2,b-a/2]);
ant7 = antenna.Rectangle( Length=a,Width=b, center=start+[-g-h-e-a/2,b-a+b/2]);
ant8 = antenna.Rectangle( Length=c,Width=a, center=start+[-g-h-e-c/2,b+b-a*1.5]);
ant9 = antenna.Rectangle( Length=a,Width=b, center=start+[-g-h-e-c+a/2,b+b-a-a+b/2]);
ant10 = antenna.Rectangle( Length=c,Width=a, center=start+[-g-h-e-c/2,b+b+b-a*2.5]);
ant11 = antenna.Rectangle( Length=a,Width=b, center=start+[-g-h-e-a/2,b+b+b-a-a-a+b/2]);
ant12 = antenna.Rectangle( Length=c,Width=a, center=start+[-g-h-e-c/2,b+b+b+b-a*3.5]);
ant13 = antenna.Rectangle( Length=a,Width=d, center=start+[-g-h-e-c+a/2,b+b+b+b-a-a-a-a+d/2]);
ant14 = antenna.Circle(center=start+[-g-h/2,f+a], Radius=R);
Newobj = ant1+ant2+ant3+ant4+ant5+ant6+ant7+ant8+ant9+ant10+ant11+ant12+ant13+ant14;
% check if the parameterized and original version are the same:
figure
show(p.Layers{1,2})
title("Original top layer")
figure
show(Newobj)
title("Parameterized top layer")
% calculate the S parameters
spar_0 = sparameters(antenna_0, (2:0.1:4)*10^9);
figure
rfplot(spar_0);
title("S parameter original design")
antenna_1 = antenna_0;
antenna_1.Layers{1,2}.Vertices = Newobj.Vertices;
spar_1 = sparameters(antenna_1, (2:0.1:4)*10^9);
figure
rfplot(spar_1);
title("S parameter parameterized version 1")
antenna_2 = antenna_0;
antenna_2.Layers{1,2} = Newobj;
spar_2 = sparameters(antenna_2, (2:0.1:4)*10^9);
figure
rfplot(spar_2);
title("S parameter parameterized version 2")
To make sure that the parameterization is correct, I take two steps. First I check if the original and paramterized version look the same. The result is as follows and shows a nearly similar polygon:
After this, I calculate the S parameters of the resulting antenna design. This is where the strange phenomenon occurs. As the code shows, I add the parameterized top layer to the antenna design in two different ways: antenna_1.Layers{1,2}.Vertices = Newobj.Vertices; and antenna_2.Layers{1,2} = Newobj;. The resulting pcbStack objects are identical but give a significantly different simulation result as shown below:
My question is: How can these two simulations (version 1 and version 2) be significantly different even though the pcbStack objects corresponding to these two simulations are identical. On top of this, how do I know which of the two is the correct simulation. Am I missing a crucial difference between the two antennas designs?
My guess is that something is wrong with antenna design version 2 since the S parameter behaviour differs so much from the original antenna design’s S parameter behaviour. It is very unlikely that this huge difference is caused by the minimal difference between the original toplayer and parameterized top layer definitions.
Best regards,
Richard Eveleens pcbstack, sparameter MATLAB Answers — New Questions
i am not getting the exact data for finite element model updating
clear;
close all;
clc;
% __________ M3=40tons
% | | K3=50*10^6
% ———- M2=45tons
% | | K2=50*10^6
% ———- M1=50tons
% | | K1=50*10^6
% — —
set-up for stiffness matrix and other
m1=50000;
m2=50000;
m3=50000;
mass=diag([m1 m2 m3]);
fprintf(‘The mass matrix n’);
disp(mass)
k1=50*10^6;
k2=50*10^6;
k3=50*10^6;
stiffness=[k1+k2 -k2 0;-k2 k2+k3 -k3;0 -k3 k3];
fprintf(‘The stiffness matrix n’);
disp(stiffness)
Natural frequency(eigen value) and Mode shape(eigen vector) calculation
[v,d]=eig(stiffness,mass);
fprintf(‘lambda value n’);
disp(d);
w=[sqrt(d)];
w1=w(1,1);
w2=w(2,2);
w3=w(3,3);
W=[w1,w2,w3];
fprintf(‘The natural frequencies of this structure are as follows(HZ) n’);
disp(W)
fprintf(‘The mode shape of the structure n’);
disp(v)
fprintf(‘lambda value n’);
disp(d);
w=[sqrt(d)];
w1=w(1,1);
w2=w(2,2);
w3=w(3,3);
W=[w1,w2,w3];
fprintf(‘The natural frequencies of this structure are as follows(HZ) n’);
disp(W)
fprintf(‘The mode shape of the structure n’);
disp(v)
Individusal mode shapes vector
fprintf(‘individusal mode shapes n’);
v1=v(:,1)
v2=v(:,2)
v3=v(:,3)
Plotting of mode shape
% height=[0;3;6;9];
% for i=1:5
% subplot(1,3,i)
% plot([0; v(:,i)],height);
% xlabel(‘mode shape’,’FontSize’,12);
% ylabel(‘Height of the structure’,’FontSize’,12);
% title([‘mode shape’, num2str(i)],’FontSize’,18);
% end
Sensitivity matrix
l1 = [1 0 0;0 0 0;0 0 0]; % DIFFERENTIATION OF STIFFNESS WRT K1
l2 = [1 -1 0;-1 1 0;0 0 0]; % DIFFERENTIATION OF STIFFNESS WRT K2
l3 = [0 0 0;0 1 -1;0 -1 1]; % DIFFERENTIATION OF STIFFNESS WRT K3
Mode shape decomposition
a111=0;
a112=(v2’*l1*v1)/(w1-w2);
a113=(v3’*l1*v1)/(w1-w3);
a121=0;
a122=(v2’*l2*v1)/(w1-w2);
a123=(v3’*l2*v1)/(w1-w3);
a131=0;
a132=(v2’*l3*v1)/(w1-w2);
a133=(v3’*l3*v1)/(w1-w3);
a211=(v1’*l1*v2)/(w2-w1);
a212=0;
a213=(v3’*l1*v2)/(w2-w3);
a221=(v1’*l2*v2)/(w2-w1);
a222=0;
a223=(v3’*l2*v2)/(w2-w3);
a231=(v1’*l3*v2)/(w2-w1);
a232=0;
a233=(v3’*l3*v2)/(w2-w3);
a311=(v1’*l1*v3)/(w3-w1);
a312=(v2’*l1*v3)/(w3-w2);
a313=0;
a321=(v1’*l2*v3)/(w3-w1);
a322=(v2’*l2*v3)/(w3-w2);
a323=0;
a331=(v1’*l3*v3)/(w3-w1);
a332=(v2’*l3*v3)/(w3-w2);
a333=0;
SENSITIVITY MATRIX FORMATION (CONSIDERING BOTH EIGEN VALUE AND MODE-SHAPE DECOMPOSITION)
s11 = v1’*l1*v1;
s12 = v1’*l2*v1;
s13 = v1’*l3*v1;
s21=a111*v1+a112*v2+a113*v3;
s22=a121*v1+a122*v2+a123*v3;
s23=a131*v1+a132*v2+a133*v3;
s31 = v2’*l1*v2;
s32 = v2’*l2*v2;
s33 = v2’*l3*v2;
s41=a211*v1+a212*v2+a213*v3;
s42=a221*v1+a222*v2+a223*v3;
s43=a231*v1+a232*v2+a233*v3;
s51 = v3’*l1*v3;
s52 = v3’*l2*v3;
s53 = v3’*l3*v3;
s61=a311*v1+a312*v2+a313*v3;
s62=a321*v1+a322*v2+a323*v3;
s63=a331*v1+a332*v2+a333*v3;
S = [s11 s12 s13;s21 s22 s23;s31 s32 s33;s41 s42 s43;s51 s52 s53;s61 s62 s63]
SENSITIVITY MATRIX FORMATION 2 (CONSIDERING ONLY EIGEN VALUE DECOMPOSITION)
% s11 = v1’*l1*v1;
% s12 = v1’*l2*v1;
% s13 = v1’*l3*v1;
% s21 = v2’*l1*v2;
% s22 = v2’*l2*v2;
% s23 = v2’*l3*v2;
% s31 = v3’*l1*v3;
% s32 = v3’*l2*v3;
% s33 = v3’*l3*v3;
% S=[s11 s12 s13;s21 s22 s23;s31 s32 s33];
UPDATING PARAMETER (CONSIDERING BOTH EIGEN VALUE AND MODE-SHAPE DECOMPOSITION)
K = [k1 k2 k3];
WA = [w1 v1′ w2 v2′ w3 v3′];
WM = [14.7257 -0.0015 -0.0027 -0.0038 35.4870 0.0029 0.0021 -0.0031 55.2413 -0.0031 0.0033 -0.0011];
K1 = K’+inv(S’*S)*S’*(WM’-WA’)
UPDATING PARAMETER 2 (CONSIDERING ONLY EIGEN VALUE DECOMPOSITION)
% K = [k1 k2 k3];
% WA = [w1 w2 w3];
% WM = [13.3221 36.7237 51.7097];
% K1 = K’+inv(S*S’)*S’*(WM’-WA’)clear;
close all;
clc;
% __________ M3=40tons
% | | K3=50*10^6
% ———- M2=45tons
% | | K2=50*10^6
% ———- M1=50tons
% | | K1=50*10^6
% — —
set-up for stiffness matrix and other
m1=50000;
m2=50000;
m3=50000;
mass=diag([m1 m2 m3]);
fprintf(‘The mass matrix n’);
disp(mass)
k1=50*10^6;
k2=50*10^6;
k3=50*10^6;
stiffness=[k1+k2 -k2 0;-k2 k2+k3 -k3;0 -k3 k3];
fprintf(‘The stiffness matrix n’);
disp(stiffness)
Natural frequency(eigen value) and Mode shape(eigen vector) calculation
[v,d]=eig(stiffness,mass);
fprintf(‘lambda value n’);
disp(d);
w=[sqrt(d)];
w1=w(1,1);
w2=w(2,2);
w3=w(3,3);
W=[w1,w2,w3];
fprintf(‘The natural frequencies of this structure are as follows(HZ) n’);
disp(W)
fprintf(‘The mode shape of the structure n’);
disp(v)
fprintf(‘lambda value n’);
disp(d);
w=[sqrt(d)];
w1=w(1,1);
w2=w(2,2);
w3=w(3,3);
W=[w1,w2,w3];
fprintf(‘The natural frequencies of this structure are as follows(HZ) n’);
disp(W)
fprintf(‘The mode shape of the structure n’);
disp(v)
Individusal mode shapes vector
fprintf(‘individusal mode shapes n’);
v1=v(:,1)
v2=v(:,2)
v3=v(:,3)
Plotting of mode shape
% height=[0;3;6;9];
% for i=1:5
% subplot(1,3,i)
% plot([0; v(:,i)],height);
% xlabel(‘mode shape’,’FontSize’,12);
% ylabel(‘Height of the structure’,’FontSize’,12);
% title([‘mode shape’, num2str(i)],’FontSize’,18);
% end
Sensitivity matrix
l1 = [1 0 0;0 0 0;0 0 0]; % DIFFERENTIATION OF STIFFNESS WRT K1
l2 = [1 -1 0;-1 1 0;0 0 0]; % DIFFERENTIATION OF STIFFNESS WRT K2
l3 = [0 0 0;0 1 -1;0 -1 1]; % DIFFERENTIATION OF STIFFNESS WRT K3
Mode shape decomposition
a111=0;
a112=(v2’*l1*v1)/(w1-w2);
a113=(v3’*l1*v1)/(w1-w3);
a121=0;
a122=(v2’*l2*v1)/(w1-w2);
a123=(v3’*l2*v1)/(w1-w3);
a131=0;
a132=(v2’*l3*v1)/(w1-w2);
a133=(v3’*l3*v1)/(w1-w3);
a211=(v1’*l1*v2)/(w2-w1);
a212=0;
a213=(v3’*l1*v2)/(w2-w3);
a221=(v1’*l2*v2)/(w2-w1);
a222=0;
a223=(v3’*l2*v2)/(w2-w3);
a231=(v1’*l3*v2)/(w2-w1);
a232=0;
a233=(v3’*l3*v2)/(w2-w3);
a311=(v1’*l1*v3)/(w3-w1);
a312=(v2’*l1*v3)/(w3-w2);
a313=0;
a321=(v1’*l2*v3)/(w3-w1);
a322=(v2’*l2*v3)/(w3-w2);
a323=0;
a331=(v1’*l3*v3)/(w3-w1);
a332=(v2’*l3*v3)/(w3-w2);
a333=0;
SENSITIVITY MATRIX FORMATION (CONSIDERING BOTH EIGEN VALUE AND MODE-SHAPE DECOMPOSITION)
s11 = v1’*l1*v1;
s12 = v1’*l2*v1;
s13 = v1’*l3*v1;
s21=a111*v1+a112*v2+a113*v3;
s22=a121*v1+a122*v2+a123*v3;
s23=a131*v1+a132*v2+a133*v3;
s31 = v2’*l1*v2;
s32 = v2’*l2*v2;
s33 = v2’*l3*v2;
s41=a211*v1+a212*v2+a213*v3;
s42=a221*v1+a222*v2+a223*v3;
s43=a231*v1+a232*v2+a233*v3;
s51 = v3’*l1*v3;
s52 = v3’*l2*v3;
s53 = v3’*l3*v3;
s61=a311*v1+a312*v2+a313*v3;
s62=a321*v1+a322*v2+a323*v3;
s63=a331*v1+a332*v2+a333*v3;
S = [s11 s12 s13;s21 s22 s23;s31 s32 s33;s41 s42 s43;s51 s52 s53;s61 s62 s63]
SENSITIVITY MATRIX FORMATION 2 (CONSIDERING ONLY EIGEN VALUE DECOMPOSITION)
% s11 = v1’*l1*v1;
% s12 = v1’*l2*v1;
% s13 = v1’*l3*v1;
% s21 = v2’*l1*v2;
% s22 = v2’*l2*v2;
% s23 = v2’*l3*v2;
% s31 = v3’*l1*v3;
% s32 = v3’*l2*v3;
% s33 = v3’*l3*v3;
% S=[s11 s12 s13;s21 s22 s23;s31 s32 s33];
UPDATING PARAMETER (CONSIDERING BOTH EIGEN VALUE AND MODE-SHAPE DECOMPOSITION)
K = [k1 k2 k3];
WA = [w1 v1′ w2 v2′ w3 v3′];
WM = [14.7257 -0.0015 -0.0027 -0.0038 35.4870 0.0029 0.0021 -0.0031 55.2413 -0.0031 0.0033 -0.0011];
K1 = K’+inv(S’*S)*S’*(WM’-WA’)
UPDATING PARAMETER 2 (CONSIDERING ONLY EIGEN VALUE DECOMPOSITION)
% K = [k1 k2 k3];
% WA = [w1 w2 w3];
% WM = [13.3221 36.7237 51.7097];
% K1 = K’+inv(S*S’)*S’*(WM’-WA’) clear;
close all;
clc;
% __________ M3=40tons
% | | K3=50*10^6
% ———- M2=45tons
% | | K2=50*10^6
% ———- M1=50tons
% | | K1=50*10^6
% — —
set-up for stiffness matrix and other
m1=50000;
m2=50000;
m3=50000;
mass=diag([m1 m2 m3]);
fprintf(‘The mass matrix n’);
disp(mass)
k1=50*10^6;
k2=50*10^6;
k3=50*10^6;
stiffness=[k1+k2 -k2 0;-k2 k2+k3 -k3;0 -k3 k3];
fprintf(‘The stiffness matrix n’);
disp(stiffness)
Natural frequency(eigen value) and Mode shape(eigen vector) calculation
[v,d]=eig(stiffness,mass);
fprintf(‘lambda value n’);
disp(d);
w=[sqrt(d)];
w1=w(1,1);
w2=w(2,2);
w3=w(3,3);
W=[w1,w2,w3];
fprintf(‘The natural frequencies of this structure are as follows(HZ) n’);
disp(W)
fprintf(‘The mode shape of the structure n’);
disp(v)
fprintf(‘lambda value n’);
disp(d);
w=[sqrt(d)];
w1=w(1,1);
w2=w(2,2);
w3=w(3,3);
W=[w1,w2,w3];
fprintf(‘The natural frequencies of this structure are as follows(HZ) n’);
disp(W)
fprintf(‘The mode shape of the structure n’);
disp(v)
Individusal mode shapes vector
fprintf(‘individusal mode shapes n’);
v1=v(:,1)
v2=v(:,2)
v3=v(:,3)
Plotting of mode shape
% height=[0;3;6;9];
% for i=1:5
% subplot(1,3,i)
% plot([0; v(:,i)],height);
% xlabel(‘mode shape’,’FontSize’,12);
% ylabel(‘Height of the structure’,’FontSize’,12);
% title([‘mode shape’, num2str(i)],’FontSize’,18);
% end
Sensitivity matrix
l1 = [1 0 0;0 0 0;0 0 0]; % DIFFERENTIATION OF STIFFNESS WRT K1
l2 = [1 -1 0;-1 1 0;0 0 0]; % DIFFERENTIATION OF STIFFNESS WRT K2
l3 = [0 0 0;0 1 -1;0 -1 1]; % DIFFERENTIATION OF STIFFNESS WRT K3
Mode shape decomposition
a111=0;
a112=(v2’*l1*v1)/(w1-w2);
a113=(v3’*l1*v1)/(w1-w3);
a121=0;
a122=(v2’*l2*v1)/(w1-w2);
a123=(v3’*l2*v1)/(w1-w3);
a131=0;
a132=(v2’*l3*v1)/(w1-w2);
a133=(v3’*l3*v1)/(w1-w3);
a211=(v1’*l1*v2)/(w2-w1);
a212=0;
a213=(v3’*l1*v2)/(w2-w3);
a221=(v1’*l2*v2)/(w2-w1);
a222=0;
a223=(v3’*l2*v2)/(w2-w3);
a231=(v1’*l3*v2)/(w2-w1);
a232=0;
a233=(v3’*l3*v2)/(w2-w3);
a311=(v1’*l1*v3)/(w3-w1);
a312=(v2’*l1*v3)/(w3-w2);
a313=0;
a321=(v1’*l2*v3)/(w3-w1);
a322=(v2’*l2*v3)/(w3-w2);
a323=0;
a331=(v1’*l3*v3)/(w3-w1);
a332=(v2’*l3*v3)/(w3-w2);
a333=0;
SENSITIVITY MATRIX FORMATION (CONSIDERING BOTH EIGEN VALUE AND MODE-SHAPE DECOMPOSITION)
s11 = v1’*l1*v1;
s12 = v1’*l2*v1;
s13 = v1’*l3*v1;
s21=a111*v1+a112*v2+a113*v3;
s22=a121*v1+a122*v2+a123*v3;
s23=a131*v1+a132*v2+a133*v3;
s31 = v2’*l1*v2;
s32 = v2’*l2*v2;
s33 = v2’*l3*v2;
s41=a211*v1+a212*v2+a213*v3;
s42=a221*v1+a222*v2+a223*v3;
s43=a231*v1+a232*v2+a233*v3;
s51 = v3’*l1*v3;
s52 = v3’*l2*v3;
s53 = v3’*l3*v3;
s61=a311*v1+a312*v2+a313*v3;
s62=a321*v1+a322*v2+a323*v3;
s63=a331*v1+a332*v2+a333*v3;
S = [s11 s12 s13;s21 s22 s23;s31 s32 s33;s41 s42 s43;s51 s52 s53;s61 s62 s63]
SENSITIVITY MATRIX FORMATION 2 (CONSIDERING ONLY EIGEN VALUE DECOMPOSITION)
% s11 = v1’*l1*v1;
% s12 = v1’*l2*v1;
% s13 = v1’*l3*v1;
% s21 = v2’*l1*v2;
% s22 = v2’*l2*v2;
% s23 = v2’*l3*v2;
% s31 = v3’*l1*v3;
% s32 = v3’*l2*v3;
% s33 = v3’*l3*v3;
% S=[s11 s12 s13;s21 s22 s23;s31 s32 s33];
UPDATING PARAMETER (CONSIDERING BOTH EIGEN VALUE AND MODE-SHAPE DECOMPOSITION)
K = [k1 k2 k3];
WA = [w1 v1′ w2 v2′ w3 v3′];
WM = [14.7257 -0.0015 -0.0027 -0.0038 35.4870 0.0029 0.0021 -0.0031 55.2413 -0.0031 0.0033 -0.0011];
K1 = K’+inv(S’*S)*S’*(WM’-WA’)
UPDATING PARAMETER 2 (CONSIDERING ONLY EIGEN VALUE DECOMPOSITION)
% K = [k1 k2 k3];
% WA = [w1 w2 w3];
% WM = [13.3221 36.7237 51.7097];
% K1 = K’+inv(S*S’)*S’*(WM’-WA’) programming, digital signal processing, matlab, c++ MATLAB Answers — New Questions
Improving chose of guesses in my fit
Hi everyone,
I do some fit on my data, and my guesses is no good enough.
Here an example of plotting my data:
And this is the code of the function that fit my data:
%fit function
function [Xmax,beta] = fit_function(x,y,peaks,t_peaks,peak_num,check_fit)
% ymax calculated analytically with Wolfram Mathematica
ymax = @(b) (2-b(2)/b(1))*(2*b(1)/b(2)-1)^(-b(2)/2/b(1));
modelfun = @(b,x) b(3)/ymax(b)*exp((x-b(4))*(b(1)-b(2))).*sech(b(1)*(x-b(4)));
bguess=[60, 15, peaks(peak_num), x(t_peaks(peak_num))];
%bguesses is [alpha, beta, amplitude, x offset]
%alpha and beta controlling of the slope of the peak, each one of them control in one slope side.
beta = nlinfit(x, y, modelfun, bguess);
Xmax=(log(-1+(2*beta(1)/beta(2)))/(2*beta(1)))+beta(4);
%check fit:
if check_fit==1
fittedCurve = modelfun(beta, x);
hold on;
plot(x, fittedCurve, ‘m’);
legend(‘Original Data’,’Fitted Curve’);
else
end
end
In this fit, I have 4 guesses. The first two of them(call alpha and beta), chosing as a constant number, according to my attempts to see what would be suitable. The other two of them is depend on the data and according to the data, the code chose the appropriate guesses. (actually is the amplitude and x offset)
So, if you look on the code, you see that 60 and 15 is the constant guesses, and the "peaks(peak_num)" and "x(t_peaks(peak_num))", is the guesses that variable according to the maximum point of the data.
The problem is that in some cases,alpha and beta, the two that are constant, sometimes suitable and sometime unsuitable.
I want to insert guesses, that will be change according to the data, exactlly like the last two guesses of the amplitude and x offset. I thinking about derivative of the peaks or something like this, but I managed to mess with it..
do you have idae for good variable guesses or how to do something that will be appropriate to any try of fitting my data?
thank you all (:Hi everyone,
I do some fit on my data, and my guesses is no good enough.
Here an example of plotting my data:
And this is the code of the function that fit my data:
%fit function
function [Xmax,beta] = fit_function(x,y,peaks,t_peaks,peak_num,check_fit)
% ymax calculated analytically with Wolfram Mathematica
ymax = @(b) (2-b(2)/b(1))*(2*b(1)/b(2)-1)^(-b(2)/2/b(1));
modelfun = @(b,x) b(3)/ymax(b)*exp((x-b(4))*(b(1)-b(2))).*sech(b(1)*(x-b(4)));
bguess=[60, 15, peaks(peak_num), x(t_peaks(peak_num))];
%bguesses is [alpha, beta, amplitude, x offset]
%alpha and beta controlling of the slope of the peak, each one of them control in one slope side.
beta = nlinfit(x, y, modelfun, bguess);
Xmax=(log(-1+(2*beta(1)/beta(2)))/(2*beta(1)))+beta(4);
%check fit:
if check_fit==1
fittedCurve = modelfun(beta, x);
hold on;
plot(x, fittedCurve, ‘m’);
legend(‘Original Data’,’Fitted Curve’);
else
end
end
In this fit, I have 4 guesses. The first two of them(call alpha and beta), chosing as a constant number, according to my attempts to see what would be suitable. The other two of them is depend on the data and according to the data, the code chose the appropriate guesses. (actually is the amplitude and x offset)
So, if you look on the code, you see that 60 and 15 is the constant guesses, and the "peaks(peak_num)" and "x(t_peaks(peak_num))", is the guesses that variable according to the maximum point of the data.
The problem is that in some cases,alpha and beta, the two that are constant, sometimes suitable and sometime unsuitable.
I want to insert guesses, that will be change according to the data, exactlly like the last two guesses of the amplitude and x offset. I thinking about derivative of the peaks or something like this, but I managed to mess with it..
do you have idae for good variable guesses or how to do something that will be appropriate to any try of fitting my data?
thank you all (: Hi everyone,
I do some fit on my data, and my guesses is no good enough.
Here an example of plotting my data:
And this is the code of the function that fit my data:
%fit function
function [Xmax,beta] = fit_function(x,y,peaks,t_peaks,peak_num,check_fit)
% ymax calculated analytically with Wolfram Mathematica
ymax = @(b) (2-b(2)/b(1))*(2*b(1)/b(2)-1)^(-b(2)/2/b(1));
modelfun = @(b,x) b(3)/ymax(b)*exp((x-b(4))*(b(1)-b(2))).*sech(b(1)*(x-b(4)));
bguess=[60, 15, peaks(peak_num), x(t_peaks(peak_num))];
%bguesses is [alpha, beta, amplitude, x offset]
%alpha and beta controlling of the slope of the peak, each one of them control in one slope side.
beta = nlinfit(x, y, modelfun, bguess);
Xmax=(log(-1+(2*beta(1)/beta(2)))/(2*beta(1)))+beta(4);
%check fit:
if check_fit==1
fittedCurve = modelfun(beta, x);
hold on;
plot(x, fittedCurve, ‘m’);
legend(‘Original Data’,’Fitted Curve’);
else
end
end
In this fit, I have 4 guesses. The first two of them(call alpha and beta), chosing as a constant number, according to my attempts to see what would be suitable. The other two of them is depend on the data and according to the data, the code chose the appropriate guesses. (actually is the amplitude and x offset)
So, if you look on the code, you see that 60 and 15 is the constant guesses, and the "peaks(peak_num)" and "x(t_peaks(peak_num))", is the guesses that variable according to the maximum point of the data.
The problem is that in some cases,alpha and beta, the two that are constant, sometimes suitable and sometime unsuitable.
I want to insert guesses, that will be change according to the data, exactlly like the last two guesses of the amplitude and x offset. I thinking about derivative of the peaks or something like this, but I managed to mess with it..
do you have idae for good variable guesses or how to do something that will be appropriate to any try of fitting my data?
thank you all (: curve fitting, matlab MATLAB Answers — New Questions
Embedded code for Randi function.it generates 625 arrays to some values, I want to know why it is generated 625 arrays of random values in initial function
y = randi([0, 11],uint32)y = randi([0, 11],uint32) y = randi([0, 11],uint32) embedded coder, matlab function, random number generator MATLAB Answers — New Questions
How do I access student submissions in MATLAB Grader?
How do I access student submissions in MATLAB Grader?How do I access student submissions in MATLAB Grader? How do I access student submissions in MATLAB Grader? grader, solution, submission, student, progress, results, grade, problem, report, assignment MATLAB Answers — New Questions
Display all the traffic going through a Can chanel, App Designer.
Hi,
I’m building an app with Matlab App Designer and i would like to display on a panel (I use a TextAera for now) all the traffic going through a Can chanel.
I did achieve to display the received ones (using receive() and canSignalTimetable()), but I can’t manage to do the same with the transmited ones.
Is there a way to do it ? Maybe easier than keeping in memory all the transmited messages and updating a timer while checking errors in the canChannel, knowing that if there’s error in transmitted messages, it seems that you can’t know wich message wasn’t sent successfully…Hi,
I’m building an app with Matlab App Designer and i would like to display on a panel (I use a TextAera for now) all the traffic going through a Can chanel.
I did achieve to display the received ones (using receive() and canSignalTimetable()), but I can’t manage to do the same with the transmited ones.
Is there a way to do it ? Maybe easier than keeping in memory all the transmited messages and updating a timer while checking errors in the canChannel, knowing that if there’s error in transmitted messages, it seems that you can’t know wich message wasn’t sent successfully… Hi,
I’m building an app with Matlab App Designer and i would like to display on a panel (I use a TextAera for now) all the traffic going through a Can chanel.
I did achieve to display the received ones (using receive() and canSignalTimetable()), but I can’t manage to do the same with the transmited ones.
Is there a way to do it ? Maybe easier than keeping in memory all the transmited messages and updating a timer while checking errors in the canChannel, knowing that if there’s error in transmitted messages, it seems that you can’t know wich message wasn’t sent successfully… canchannel, appdesigner, transmit, receive MATLAB Answers — New Questions
Check if New Desktop addon is used in current session
Is there a way to check programmatically if in the New Desktop is active in the current session (I want to detect this info in a startup file)?Is there a way to check programmatically if in the New Desktop is active in the current session (I want to detect this info in a startup file)? Is there a way to check programmatically if in the New Desktop is active in the current session (I want to detect this info in a startup file)? new desktop, matlab MATLAB Answers — New Questions
Calculating Inductance of parallel DC cables
I am currently doing a short-circuit analysis of a vessel. The vessel has a DC busbar where all the converters are connected to it. Since the inductance value of the cables holds significant importance when analyzing short-circuits I tried to calculate and add inductance & resistance in simscape environment to model these cables. IEC documents give inductance calculations for single core cables. I want to calculate inductance for multiple single core cables or cables with more than 1 core inside. Is there any general approach I can use, or any source that might be helpfull?I am currently doing a short-circuit analysis of a vessel. The vessel has a DC busbar where all the converters are connected to it. Since the inductance value of the cables holds significant importance when analyzing short-circuits I tried to calculate and add inductance & resistance in simscape environment to model these cables. IEC documents give inductance calculations for single core cables. I want to calculate inductance for multiple single core cables or cables with more than 1 core inside. Is there any general approach I can use, or any source that might be helpfull? I am currently doing a short-circuit analysis of a vessel. The vessel has a DC busbar where all the converters are connected to it. Since the inductance value of the cables holds significant importance when analyzing short-circuits I tried to calculate and add inductance & resistance in simscape environment to model these cables. IEC documents give inductance calculations for single core cables. I want to calculate inductance for multiple single core cables or cables with more than 1 core inside. Is there any general approach I can use, or any source that might be helpfull? simscape MATLAB Answers — New Questions