Tag Archives: matlab
images from radio telescopes using matlab, simulink, and sdr
hello i would like to ask how to generate images from radio telescopes using matlab, simulink, and sdr. thanks very much.hello i would like to ask how to generate images from radio telescopes using matlab, simulink, and sdr. thanks very much. hello i would like to ask how to generate images from radio telescopes using matlab, simulink, and sdr. thanks very much. images, radio telescopes MATLAB Answers — New Questions
error in the code
erroe in string(j,n)=string(k,n);
for k=1:Npop
for j=1:dim
busLocation(j,k)=busd(busLocation(j,k),1);
end
sdf= unique(busLocation(:,k));
while length(sdf)<dim
sdf=randi([2 length(busd(:,1))],dim,1);
for j=1:dim
sdf(j)=busd(sdf(j),1);
end
busLocation(:,k)=sdf;
sdf= unique(busLocation(:,k));
end
end
ndif = [0.28; 0.35; 0.39; 0.35; 0.27; 0.34; 0.40; 0.34; 0.25; 0.32];
for k = 1:Npop
mdif(k)= ndif(k);
end
nsw=length(string);
mpop = round(Npop/4);
for j = 1:mpop
minman = min(mdif(:));
for k = 1:Npop
if mdif(k)== minman
for n=1:nsw
string(j,n)=string(k,n);
end
mdif(k)= 1010;
break;
end
end
end
for j = 1:(Npop-mpop)
for bits=1:nsw
string(mpop +j,bits) = string(j,bits);
end
end ; enderroe in string(j,n)=string(k,n);
for k=1:Npop
for j=1:dim
busLocation(j,k)=busd(busLocation(j,k),1);
end
sdf= unique(busLocation(:,k));
while length(sdf)<dim
sdf=randi([2 length(busd(:,1))],dim,1);
for j=1:dim
sdf(j)=busd(sdf(j),1);
end
busLocation(:,k)=sdf;
sdf= unique(busLocation(:,k));
end
end
ndif = [0.28; 0.35; 0.39; 0.35; 0.27; 0.34; 0.40; 0.34; 0.25; 0.32];
for k = 1:Npop
mdif(k)= ndif(k);
end
nsw=length(string);
mpop = round(Npop/4);
for j = 1:mpop
minman = min(mdif(:));
for k = 1:Npop
if mdif(k)== minman
for n=1:nsw
string(j,n)=string(k,n);
end
mdif(k)= 1010;
break;
end
end
end
for j = 1:(Npop-mpop)
for bits=1:nsw
string(mpop +j,bits) = string(j,bits);
end
end ; end erroe in string(j,n)=string(k,n);
for k=1:Npop
for j=1:dim
busLocation(j,k)=busd(busLocation(j,k),1);
end
sdf= unique(busLocation(:,k));
while length(sdf)<dim
sdf=randi([2 length(busd(:,1))],dim,1);
for j=1:dim
sdf(j)=busd(sdf(j),1);
end
busLocation(:,k)=sdf;
sdf= unique(busLocation(:,k));
end
end
ndif = [0.28; 0.35; 0.39; 0.35; 0.27; 0.34; 0.40; 0.34; 0.25; 0.32];
for k = 1:Npop
mdif(k)= ndif(k);
end
nsw=length(string);
mpop = round(Npop/4);
for j = 1:mpop
minman = min(mdif(:));
for k = 1:Npop
if mdif(k)== minman
for n=1:nsw
string(j,n)=string(k,n);
end
mdif(k)= 1010;
break;
end
end
end
for j = 1:(Npop-mpop)
for bits=1:nsw
string(mpop +j,bits) = string(j,bits);
end
end ; end for study MATLAB Answers — New Questions
Oral Dose Not Exhibiting Absorption/Bioavailability in Simulation
Hello! I am trying to use this model "Estimating the Bioavailibility of a Drug" that I found here, to do a simultaneous fitting of my IV infusion and P.O. blood concentration time profile. I implemented a two compartment model as well. For some reason, when I am running a simulation the oral dose exhibits a bioavailbility of >= 1, even though I have the parameter F set as 0.2. I attached images of my simulation curve (green is oral dose), model diagram, ODEs, and dosing setup. I’m thinking it might have something to do with the way I set up the dosing, but please let me know if you have any advice on how I should troubleshoot this. I am using R2024a. Please let me know if I should include anything else. Thanks!Hello! I am trying to use this model "Estimating the Bioavailibility of a Drug" that I found here, to do a simultaneous fitting of my IV infusion and P.O. blood concentration time profile. I implemented a two compartment model as well. For some reason, when I am running a simulation the oral dose exhibits a bioavailbility of >= 1, even though I have the parameter F set as 0.2. I attached images of my simulation curve (green is oral dose), model diagram, ODEs, and dosing setup. I’m thinking it might have something to do with the way I set up the dosing, but please let me know if you have any advice on how I should troubleshoot this. I am using R2024a. Please let me know if I should include anything else. Thanks! Hello! I am trying to use this model "Estimating the Bioavailibility of a Drug" that I found here, to do a simultaneous fitting of my IV infusion and P.O. blood concentration time profile. I implemented a two compartment model as well. For some reason, when I am running a simulation the oral dose exhibits a bioavailbility of >= 1, even though I have the parameter F set as 0.2. I attached images of my simulation curve (green is oral dose), model diagram, ODEs, and dosing setup. I’m thinking it might have something to do with the way I set up the dosing, but please let me know if you have any advice on how I should troubleshoot this. I am using R2024a. Please let me know if I should include anything else. Thanks! matlab, simbiology, simulation, oral dose, dosing, bioavailibility MATLAB Answers — New Questions
Second Order Laplace solving doesn’t work (‘Unable to find explicit solution’)
I’m trying to solve an ODE using Laplace method, but I’m stuck on solving the equation
Here’s my code:
syms t x(t) s X(s);
% PARAMETERS (tried to do symbolically but it was more diffcult)
m = 1;
k = 0.5;
xi = 1.2;
c = xi*2*sqrt(k*m)
f0 = 1;
w = 0.1;
dx = diff(x, t, 1);
ddx = diff(x, t, 2);
% INITIAL CONDITIONS
x0 = 0;
dx0 = 0;
newton = m*ddx+ c*dx +k*x;
f = f0*cos(w*t);
lteqn = laplace(newton, t, s)
lefteqn = subs(lteqn,{laplace(x(t), t, s), x(0),dx(0)},{X(s), x0, dx0})
F_s = laplace(f, t, s);
simplify(solve(lefteqn == F_s, X(s)))
I can’t believe MATLAB cannot solve this easy equation. I think I’m missing something.
Thank you guysI’m trying to solve an ODE using Laplace method, but I’m stuck on solving the equation
Here’s my code:
syms t x(t) s X(s);
% PARAMETERS (tried to do symbolically but it was more diffcult)
m = 1;
k = 0.5;
xi = 1.2;
c = xi*2*sqrt(k*m)
f0 = 1;
w = 0.1;
dx = diff(x, t, 1);
ddx = diff(x, t, 2);
% INITIAL CONDITIONS
x0 = 0;
dx0 = 0;
newton = m*ddx+ c*dx +k*x;
f = f0*cos(w*t);
lteqn = laplace(newton, t, s)
lefteqn = subs(lteqn,{laplace(x(t), t, s), x(0),dx(0)},{X(s), x0, dx0})
F_s = laplace(f, t, s);
simplify(solve(lefteqn == F_s, X(s)))
I can’t believe MATLAB cannot solve this easy equation. I think I’m missing something.
Thank you guys I’m trying to solve an ODE using Laplace method, but I’m stuck on solving the equation
Here’s my code:
syms t x(t) s X(s);
% PARAMETERS (tried to do symbolically but it was more diffcult)
m = 1;
k = 0.5;
xi = 1.2;
c = xi*2*sqrt(k*m)
f0 = 1;
w = 0.1;
dx = diff(x, t, 1);
ddx = diff(x, t, 2);
% INITIAL CONDITIONS
x0 = 0;
dx0 = 0;
newton = m*ddx+ c*dx +k*x;
f = f0*cos(w*t);
lteqn = laplace(newton, t, s)
lefteqn = subs(lteqn,{laplace(x(t), t, s), x(0),dx(0)},{X(s), x0, dx0})
F_s = laplace(f, t, s);
simplify(solve(lefteqn == F_s, X(s)))
I can’t believe MATLAB cannot solve this easy equation. I think I’m missing something.
Thank you guys solve, ode, laplace, matlab MATLAB Answers — New Questions
How to tune PI controllers of MIMO system?
How to tune the PI controllers for this kind of MIMO system as shown in the picture? Any resources regadring this would be appreciated.How to tune the PI controllers for this kind of MIMO system as shown in the picture? Any resources regadring this would be appreciated. How to tune the PI controllers for this kind of MIMO system as shown in the picture? Any resources regadring this would be appreciated. mimo system, pi tuning MATLAB Answers — New Questions
How do I pass username and password for a named user license with no GUI on linux
I have Matlab R2024A installed on a linux computer with no GUI (terminal only) I want to run matlab -licmode onlinelicensing but also pass my username and password in one line so I don’t have to input it in. Is that possible ?I have Matlab R2024A installed on a linux computer with no GUI (terminal only) I want to run matlab -licmode onlinelicensing but also pass my username and password in one line so I don’t have to input it in. Is that possible ? I have Matlab R2024A installed on a linux computer with no GUI (terminal only) I want to run matlab -licmode onlinelicensing but also pass my username and password in one line so I don’t have to input it in. Is that possible ? license MATLAB Answers — New Questions
How can I replace the upper off diagonal(super diagonal) and lower off diagonal(sub diagonal) of a matrix?
Given a symmetric tridiagonal matrix T generated by
n=5;
p=1;
q=1.7;
r=1;
T=full(gallery(‘tridiagonal’,n,p,q,r));
T=[1.8 1 0 0 0;1 1.8 0 0 0;0 1 1.8 1 0;0 0 1 1.8 1;0 0 0 1 1.8]
How do I change the 1 1 1 1 on both upper and lower off diagonal to 1 0 1 0? What if n is arbitrary, is there any code that fix the off diagonals to a desired vector?Given a symmetric tridiagonal matrix T generated by
n=5;
p=1;
q=1.7;
r=1;
T=full(gallery(‘tridiagonal’,n,p,q,r));
T=[1.8 1 0 0 0;1 1.8 0 0 0;0 1 1.8 1 0;0 0 1 1.8 1;0 0 0 1 1.8]
How do I change the 1 1 1 1 on both upper and lower off diagonal to 1 0 1 0? What if n is arbitrary, is there any code that fix the off diagonals to a desired vector? Given a symmetric tridiagonal matrix T generated by
n=5;
p=1;
q=1.7;
r=1;
T=full(gallery(‘tridiagonal’,n,p,q,r));
T=[1.8 1 0 0 0;1 1.8 0 0 0;0 1 1.8 1 0;0 0 1 1.8 1;0 0 0 1 1.8]
How do I change the 1 1 1 1 on both upper and lower off diagonal to 1 0 1 0? What if n is arbitrary, is there any code that fix the off diagonals to a desired vector? symmetric, tridiagonal, off diagonal MATLAB Answers — New Questions
Can I use the MATLAB Package Manager on Windows without admin permissions?
Can I use the MATLAB Package Manager (MPM) on Windows without administrative privileges?Can I use the MATLAB Package Manager (MPM) on Windows without administrative privileges? Can I use the MATLAB Package Manager (MPM) on Windows without administrative privileges? MATLAB Answers — New Questions
Generating a Sin wave that changes frequency pseudo randomly after each period?
Im trying to program a sig gen that uses mathlad and was wondering if there is a way to generate a sin wave that changes frequency psuedo randomly after each period for a given lenght time? Is there a shortcut or does matlab have a library to accomplish this task?Im trying to program a sig gen that uses mathlad and was wondering if there is a way to generate a sin wave that changes frequency psuedo randomly after each period for a given lenght time? Is there a shortcut or does matlab have a library to accomplish this task? Im trying to program a sig gen that uses mathlad and was wondering if there is a way to generate a sin wave that changes frequency psuedo randomly after each period for a given lenght time? Is there a shortcut or does matlab have a library to accomplish this task? digital signal processing, signal processing, signal MATLAB Answers — New Questions
Error using webwrite: “Recv failure: Connection was reset”
I am using webwrite and get the following error:
"Error connecting to [targeturl]: Recv failure: Connection was reset"
This is the matlab code:
options = weboptions(‘MediaType’,’application/x-www-form-urlencoded’,’Timeout’,Inf);
response = webwrite(url,data,options);
When I execute my equivalent url/data call from Chrome, it works just fine.
It’s knowingly a semi-long wait time for the response. (I’m requesting my target server to build a large CSV dataset then respond with the URL for the CSV). ‘response’ is simply a text string of the CSV url. (Separate code to fetch the CSV works just fine)
The url/data call used to work fine with a Timeout of 900s, then I increased my request to ask for a dataset about 10%-15% larger. Now I keep getting the above error, even though the Timeout upper limit should actually be a little over 2000s. I’ve also tried manual Timeout thesholds at 1000, 1200, 1800, etc to no avail.
It seems like even thought the Timeout is 2000+… something is still timing out…I am using webwrite and get the following error:
"Error connecting to [targeturl]: Recv failure: Connection was reset"
This is the matlab code:
options = weboptions(‘MediaType’,’application/x-www-form-urlencoded’,’Timeout’,Inf);
response = webwrite(url,data,options);
When I execute my equivalent url/data call from Chrome, it works just fine.
It’s knowingly a semi-long wait time for the response. (I’m requesting my target server to build a large CSV dataset then respond with the URL for the CSV). ‘response’ is simply a text string of the CSV url. (Separate code to fetch the CSV works just fine)
The url/data call used to work fine with a Timeout of 900s, then I increased my request to ask for a dataset about 10%-15% larger. Now I keep getting the above error, even though the Timeout upper limit should actually be a little over 2000s. I’ve also tried manual Timeout thesholds at 1000, 1200, 1800, etc to no avail.
It seems like even thought the Timeout is 2000+… something is still timing out… I am using webwrite and get the following error:
"Error connecting to [targeturl]: Recv failure: Connection was reset"
This is the matlab code:
options = weboptions(‘MediaType’,’application/x-www-form-urlencoded’,’Timeout’,Inf);
response = webwrite(url,data,options);
When I execute my equivalent url/data call from Chrome, it works just fine.
It’s knowingly a semi-long wait time for the response. (I’m requesting my target server to build a large CSV dataset then respond with the URL for the CSV). ‘response’ is simply a text string of the CSV url. (Separate code to fetch the CSV works just fine)
The url/data call used to work fine with a Timeout of 900s, then I increased my request to ask for a dataset about 10%-15% larger. Now I keep getting the above error, even though the Timeout upper limit should actually be a little over 2000s. I’ve also tried manual Timeout thesholds at 1000, 1200, 1800, etc to no avail.
It seems like even thought the Timeout is 2000+… something is still timing out… webwrite, timeout MATLAB Answers — New Questions
How to fit a nonparametric distribution to a sample of known percentile values
Hello everyone
I have a sample of percentile values that describe the distribution of possible earthquake acceleration levels that lead to the failure of a building component. I would like to fit a nonparametric model to these data. I know that, for a random sample of these earthquake acceleration levels, I coiuld fit a nonparametric density using the the ksdensity function but is there a way to do a similar fit for the cumulative distribution function of this function?
Many thanks
Example data:
percentiles = [3 11 27 33 52 66 75 87 92];
acc = [0.3339 0.3595 0.4209 0.4283 0.4645 0.5010 0.5080 0.5713 0.6025];Hello everyone
I have a sample of percentile values that describe the distribution of possible earthquake acceleration levels that lead to the failure of a building component. I would like to fit a nonparametric model to these data. I know that, for a random sample of these earthquake acceleration levels, I coiuld fit a nonparametric density using the the ksdensity function but is there a way to do a similar fit for the cumulative distribution function of this function?
Many thanks
Example data:
percentiles = [3 11 27 33 52 66 75 87 92];
acc = [0.3339 0.3595 0.4209 0.4283 0.4645 0.5010 0.5080 0.5713 0.6025]; Hello everyone
I have a sample of percentile values that describe the distribution of possible earthquake acceleration levels that lead to the failure of a building component. I would like to fit a nonparametric model to these data. I know that, for a random sample of these earthquake acceleration levels, I coiuld fit a nonparametric density using the the ksdensity function but is there a way to do a similar fit for the cumulative distribution function of this function?
Many thanks
Example data:
percentiles = [3 11 27 33 52 66 75 87 92];
acc = [0.3339 0.3595 0.4209 0.4283 0.4645 0.5010 0.5080 0.5713 0.6025]; nonparametric distribution fitting, percentile data MATLAB Answers — New Questions
Nozzle Design Error: Matrix is singular, close to singular or badly scaled. Results may be inaccurate. RCOND = NaN.
Greetings everyone, I am trying to look into a code found here corydodson/NozzleDesign: Design of supersonic nozzles (github.com). However, I run into an error whenever I run the code which reads "Matrix is singular, close to singular or badly scaled. Results may be inaccurate. RCOND = NaN. " I belive the error comes from this internalnode.m function. x,y are the coordinates, t0 is the temperature and d can be 0 or 1 depending on the user. Anyway I can resolve this? Any help is appreciated!
function [xOut,yOut,uOut,vOut] = internalnode(t0,species,moleFracs,x,y,u,v,d)
h0 = mixprop(‘h’,species,moleFracs,t0);
r = mixprop(‘r’,species,moleFracs)*1000;
L = length(x);
minus = logical([ones(L – 1,1);0]);
plus = logical([0;ones(L – 1,1)]);
xm = x(minus);
xmCalc = xm;
xp = x(plus);
ym = y(minus);
ymCalc = ym;
yp = y(plus);
ypCalc = yp;
um = u(minus);
umCalc = um;
up = u(plus);
upCalc = up;
vm = v(minus);
vmCalc = vm;
vp = v(plus);
vpCalc = vp;
sp = vm;
N = 20;
err = 1e-4;
notConv = true(1,4);
for i = 1:N
ymCalc = (ym + ymCalc)/2;
ypCalc = (yp + ypCalc)/2;
umCalc = (um + umCalc)/2;
upCalc = (up + upCalc)/2;
vmCalc = (vm + vmCalc)/2;
vpCalc = (vp + vpCalc)/2;
uCalc = [umCalc;upCalc(end)];
vCalc = [vmCalc;vpCalc(end)];
vMag = sqrt(uCalc.^2 + vCalc.^2);
h = h0 – vMag.^2/2000;
t = tempfromprop(species,moleFracs,’h’,h);
g = mixprop(‘gamma’,species,moleFracs,t);
a = sqrt(r*g.*t);
am = a(minus);
ap = a(plus);
mu = asind(a./vMag);
mum = mu(minus);
mup = mu(plus);
theta = atand(vCalc./uCalc);
thetam = theta(minus);
thetap = theta(plus);
lm = tand(thetam – mum);
lp = tand(thetap + mup);
q = uCalc.^2 – a.^2;
qm = q(minus);
qp = q(plus);
rm = 2*umCalc.*vmCalc – qm.*lm;
rp = 2*upCalc.*vpCalc – qp.*lp;
sm = d*am.^2.*vmCalc./ymCalc;
switch isempty(sp(ypCalc == 0))
case 1
sp = d*ap.^2.*vpCalc./ypCalc;
otherwise
sp(ypCalc ~= 0) = d*ap(ypCalc ~= 0).^2.*vpCalc(ypCalc ~= 0)./ypCalc(ypCalc ~= 0);
sp(ypCalc == 0) = sm(end);
end
A = zeros(L);
B = zeros(L,1);
for j = 1:L – 1
A(2*(j – 1) + 1:2*j,2*(j – 1) + 1:2*j) = [1,-lp(j);…
1,-lm(j)];
B(2*(j – 1) + 1:2*j) = [yp(j) – lp(j)*xp(j);…
ym(j) – lm(j)*xm(j)];
end
X = AB;
ymCalc = X(1:2:end);
ypCalc = ymCalc;
xmCalc = X(2:2:end);
xpCalc = xmCalc;
for j = 1:L – 1
A(2*(j – 1) + 1:2*j,2*(j – 1) + 1:2*j) = [qp(j),rp(j);…
qm(j),rm(j)];
B(2*(j – 1) + 1:2*j) = [sp(j)*(xpCalc(j) – xp(j)) + qp(j)*up(j) + rp(j)*vp(j);…
sm(j)*(xmCalc(j) – xm(j)) + qm(j)*um(j) + rm(j)*vm(j)];
end
X = AB;
umCalc = X(1:2:end);
upCalc = umCalc;
vmCalc = X(2:2:end);
vpCalc = vmCalc;
switch i ~= 1
case 1
notConv = abs([xmCalc,ymCalc,umCalc,vmCalc]./check0 – 1) > err;
end
check0 = [xmCalc,ymCalc,umCalc,vmCalc];
switch sum(sum(notConv)) == 0
case 1
break
end
switch isnan(xmCalc) | isnan(ymCalc) | isnan(umCalc) | isnan(vmCalc)
case 1
break
end
end
xOut = xmCalc;
yOut = ymCalc;
uOut = umCalc;
vOut = vmCalc;
endGreetings everyone, I am trying to look into a code found here corydodson/NozzleDesign: Design of supersonic nozzles (github.com). However, I run into an error whenever I run the code which reads "Matrix is singular, close to singular or badly scaled. Results may be inaccurate. RCOND = NaN. " I belive the error comes from this internalnode.m function. x,y are the coordinates, t0 is the temperature and d can be 0 or 1 depending on the user. Anyway I can resolve this? Any help is appreciated!
function [xOut,yOut,uOut,vOut] = internalnode(t0,species,moleFracs,x,y,u,v,d)
h0 = mixprop(‘h’,species,moleFracs,t0);
r = mixprop(‘r’,species,moleFracs)*1000;
L = length(x);
minus = logical([ones(L – 1,1);0]);
plus = logical([0;ones(L – 1,1)]);
xm = x(minus);
xmCalc = xm;
xp = x(plus);
ym = y(minus);
ymCalc = ym;
yp = y(plus);
ypCalc = yp;
um = u(minus);
umCalc = um;
up = u(plus);
upCalc = up;
vm = v(minus);
vmCalc = vm;
vp = v(plus);
vpCalc = vp;
sp = vm;
N = 20;
err = 1e-4;
notConv = true(1,4);
for i = 1:N
ymCalc = (ym + ymCalc)/2;
ypCalc = (yp + ypCalc)/2;
umCalc = (um + umCalc)/2;
upCalc = (up + upCalc)/2;
vmCalc = (vm + vmCalc)/2;
vpCalc = (vp + vpCalc)/2;
uCalc = [umCalc;upCalc(end)];
vCalc = [vmCalc;vpCalc(end)];
vMag = sqrt(uCalc.^2 + vCalc.^2);
h = h0 – vMag.^2/2000;
t = tempfromprop(species,moleFracs,’h’,h);
g = mixprop(‘gamma’,species,moleFracs,t);
a = sqrt(r*g.*t);
am = a(minus);
ap = a(plus);
mu = asind(a./vMag);
mum = mu(minus);
mup = mu(plus);
theta = atand(vCalc./uCalc);
thetam = theta(minus);
thetap = theta(plus);
lm = tand(thetam – mum);
lp = tand(thetap + mup);
q = uCalc.^2 – a.^2;
qm = q(minus);
qp = q(plus);
rm = 2*umCalc.*vmCalc – qm.*lm;
rp = 2*upCalc.*vpCalc – qp.*lp;
sm = d*am.^2.*vmCalc./ymCalc;
switch isempty(sp(ypCalc == 0))
case 1
sp = d*ap.^2.*vpCalc./ypCalc;
otherwise
sp(ypCalc ~= 0) = d*ap(ypCalc ~= 0).^2.*vpCalc(ypCalc ~= 0)./ypCalc(ypCalc ~= 0);
sp(ypCalc == 0) = sm(end);
end
A = zeros(L);
B = zeros(L,1);
for j = 1:L – 1
A(2*(j – 1) + 1:2*j,2*(j – 1) + 1:2*j) = [1,-lp(j);…
1,-lm(j)];
B(2*(j – 1) + 1:2*j) = [yp(j) – lp(j)*xp(j);…
ym(j) – lm(j)*xm(j)];
end
X = AB;
ymCalc = X(1:2:end);
ypCalc = ymCalc;
xmCalc = X(2:2:end);
xpCalc = xmCalc;
for j = 1:L – 1
A(2*(j – 1) + 1:2*j,2*(j – 1) + 1:2*j) = [qp(j),rp(j);…
qm(j),rm(j)];
B(2*(j – 1) + 1:2*j) = [sp(j)*(xpCalc(j) – xp(j)) + qp(j)*up(j) + rp(j)*vp(j);…
sm(j)*(xmCalc(j) – xm(j)) + qm(j)*um(j) + rm(j)*vm(j)];
end
X = AB;
umCalc = X(1:2:end);
upCalc = umCalc;
vmCalc = X(2:2:end);
vpCalc = vmCalc;
switch i ~= 1
case 1
notConv = abs([xmCalc,ymCalc,umCalc,vmCalc]./check0 – 1) > err;
end
check0 = [xmCalc,ymCalc,umCalc,vmCalc];
switch sum(sum(notConv)) == 0
case 1
break
end
switch isnan(xmCalc) | isnan(ymCalc) | isnan(umCalc) | isnan(vmCalc)
case 1
break
end
end
xOut = xmCalc;
yOut = ymCalc;
uOut = umCalc;
vOut = vmCalc;
end Greetings everyone, I am trying to look into a code found here corydodson/NozzleDesign: Design of supersonic nozzles (github.com). However, I run into an error whenever I run the code which reads "Matrix is singular, close to singular or badly scaled. Results may be inaccurate. RCOND = NaN. " I belive the error comes from this internalnode.m function. x,y are the coordinates, t0 is the temperature and d can be 0 or 1 depending on the user. Anyway I can resolve this? Any help is appreciated!
function [xOut,yOut,uOut,vOut] = internalnode(t0,species,moleFracs,x,y,u,v,d)
h0 = mixprop(‘h’,species,moleFracs,t0);
r = mixprop(‘r’,species,moleFracs)*1000;
L = length(x);
minus = logical([ones(L – 1,1);0]);
plus = logical([0;ones(L – 1,1)]);
xm = x(minus);
xmCalc = xm;
xp = x(plus);
ym = y(minus);
ymCalc = ym;
yp = y(plus);
ypCalc = yp;
um = u(minus);
umCalc = um;
up = u(plus);
upCalc = up;
vm = v(minus);
vmCalc = vm;
vp = v(plus);
vpCalc = vp;
sp = vm;
N = 20;
err = 1e-4;
notConv = true(1,4);
for i = 1:N
ymCalc = (ym + ymCalc)/2;
ypCalc = (yp + ypCalc)/2;
umCalc = (um + umCalc)/2;
upCalc = (up + upCalc)/2;
vmCalc = (vm + vmCalc)/2;
vpCalc = (vp + vpCalc)/2;
uCalc = [umCalc;upCalc(end)];
vCalc = [vmCalc;vpCalc(end)];
vMag = sqrt(uCalc.^2 + vCalc.^2);
h = h0 – vMag.^2/2000;
t = tempfromprop(species,moleFracs,’h’,h);
g = mixprop(‘gamma’,species,moleFracs,t);
a = sqrt(r*g.*t);
am = a(minus);
ap = a(plus);
mu = asind(a./vMag);
mum = mu(minus);
mup = mu(plus);
theta = atand(vCalc./uCalc);
thetam = theta(minus);
thetap = theta(plus);
lm = tand(thetam – mum);
lp = tand(thetap + mup);
q = uCalc.^2 – a.^2;
qm = q(minus);
qp = q(plus);
rm = 2*umCalc.*vmCalc – qm.*lm;
rp = 2*upCalc.*vpCalc – qp.*lp;
sm = d*am.^2.*vmCalc./ymCalc;
switch isempty(sp(ypCalc == 0))
case 1
sp = d*ap.^2.*vpCalc./ypCalc;
otherwise
sp(ypCalc ~= 0) = d*ap(ypCalc ~= 0).^2.*vpCalc(ypCalc ~= 0)./ypCalc(ypCalc ~= 0);
sp(ypCalc == 0) = sm(end);
end
A = zeros(L);
B = zeros(L,1);
for j = 1:L – 1
A(2*(j – 1) + 1:2*j,2*(j – 1) + 1:2*j) = [1,-lp(j);…
1,-lm(j)];
B(2*(j – 1) + 1:2*j) = [yp(j) – lp(j)*xp(j);…
ym(j) – lm(j)*xm(j)];
end
X = AB;
ymCalc = X(1:2:end);
ypCalc = ymCalc;
xmCalc = X(2:2:end);
xpCalc = xmCalc;
for j = 1:L – 1
A(2*(j – 1) + 1:2*j,2*(j – 1) + 1:2*j) = [qp(j),rp(j);…
qm(j),rm(j)];
B(2*(j – 1) + 1:2*j) = [sp(j)*(xpCalc(j) – xp(j)) + qp(j)*up(j) + rp(j)*vp(j);…
sm(j)*(xmCalc(j) – xm(j)) + qm(j)*um(j) + rm(j)*vm(j)];
end
X = AB;
umCalc = X(1:2:end);
upCalc = umCalc;
vmCalc = X(2:2:end);
vpCalc = vmCalc;
switch i ~= 1
case 1
notConv = abs([xmCalc,ymCalc,umCalc,vmCalc]./check0 – 1) > err;
end
check0 = [xmCalc,ymCalc,umCalc,vmCalc];
switch sum(sum(notConv)) == 0
case 1
break
end
switch isnan(xmCalc) | isnan(ymCalc) | isnan(umCalc) | isnan(vmCalc)
case 1
break
end
end
xOut = xmCalc;
yOut = ymCalc;
uOut = umCalc;
vOut = vmCalc;
end #matlab, #nozzle, #method of characteristics, #singular MATLAB Answers — New Questions
Does variation point blocks get generated for OPERATION-INVOKED-EVENT runnables ?
I have added Variation points for a runnable like below from systemdesk
<RUNNABLE-ENTITY UUID="32a97bd4-8cc3-443b-979d-8423bf9af7c1">
<SHORT-NAME>ActvAirDamCtrlDTIStart</SHORT-NAME>
<MINIMUM-START-INTERVAL>0</MINIMUM-START-INTERVAL>
<CAN-BE-INVOKED-CONCURRENTLY>true</CAN-BE-INVOKED-CONCURRENTLY>
<SYMBOL>ActvAirDamCtrl_ActvAirDamCtrlDTIStart</SYMBOL>
<VARIATION-POINT>
<SHORT-LABEL>ActvAirDamVPnt</SHORT-LABEL>
<SW-SYSCOND BINDING-TIME="PRE-COMPILE-TIME">
<SYSC-STRING-REF DEST="SW-SYSTEMCONST">/FCAVariants/VariantManagement/BuildActvAirDam</SYSC-STRING-REF>==1</SW-SYSCOND>
</VARIATION-POINT>
</RUNNABLE-ENTITY>
But once the model is created the runnable does not contain this variation pointI have added Variation points for a runnable like below from systemdesk
<RUNNABLE-ENTITY UUID="32a97bd4-8cc3-443b-979d-8423bf9af7c1">
<SHORT-NAME>ActvAirDamCtrlDTIStart</SHORT-NAME>
<MINIMUM-START-INTERVAL>0</MINIMUM-START-INTERVAL>
<CAN-BE-INVOKED-CONCURRENTLY>true</CAN-BE-INVOKED-CONCURRENTLY>
<SYMBOL>ActvAirDamCtrl_ActvAirDamCtrlDTIStart</SYMBOL>
<VARIATION-POINT>
<SHORT-LABEL>ActvAirDamVPnt</SHORT-LABEL>
<SW-SYSCOND BINDING-TIME="PRE-COMPILE-TIME">
<SYSC-STRING-REF DEST="SW-SYSTEMCONST">/FCAVariants/VariantManagement/BuildActvAirDam</SYSC-STRING-REF>==1</SW-SYSCOND>
</VARIATION-POINT>
</RUNNABLE-ENTITY>
But once the model is created the runnable does not contain this variation point I have added Variation points for a runnable like below from systemdesk
<RUNNABLE-ENTITY UUID="32a97bd4-8cc3-443b-979d-8423bf9af7c1">
<SHORT-NAME>ActvAirDamCtrlDTIStart</SHORT-NAME>
<MINIMUM-START-INTERVAL>0</MINIMUM-START-INTERVAL>
<CAN-BE-INVOKED-CONCURRENTLY>true</CAN-BE-INVOKED-CONCURRENTLY>
<SYMBOL>ActvAirDamCtrl_ActvAirDamCtrlDTIStart</SYMBOL>
<VARIATION-POINT>
<SHORT-LABEL>ActvAirDamVPnt</SHORT-LABEL>
<SW-SYSCOND BINDING-TIME="PRE-COMPILE-TIME">
<SYSC-STRING-REF DEST="SW-SYSTEMCONST">/FCAVariants/VariantManagement/BuildActvAirDam</SYSC-STRING-REF>==1</SW-SYSCOND>
</VARIATION-POINT>
</RUNNABLE-ENTITY>
But once the model is created the runnable does not contain this variation point model, simulink, matlab MATLAB Answers — New Questions
How do I assign an index value to a function output?
Using R2014b. I have a function called within a for loop which returns lots of outputs. I want to assign an index value for each output of the function as the loop runs. Something like:
for ind = 1:n
[output1(ind),output2(ind), …] = function(inputs)
end
This doesn’t appear to work (results in an error). Is there an easy way to code this without doing:
output1(ind) = output1;
output2(ind) = output2;
for each variable after the function call?Using R2014b. I have a function called within a for loop which returns lots of outputs. I want to assign an index value for each output of the function as the loop runs. Something like:
for ind = 1:n
[output1(ind),output2(ind), …] = function(inputs)
end
This doesn’t appear to work (results in an error). Is there an easy way to code this without doing:
output1(ind) = output1;
output2(ind) = output2;
for each variable after the function call? Using R2014b. I have a function called within a for loop which returns lots of outputs. I want to assign an index value for each output of the function as the loop runs. Something like:
for ind = 1:n
[output1(ind),output2(ind), …] = function(inputs)
end
This doesn’t appear to work (results in an error). Is there an easy way to code this without doing:
output1(ind) = output1;
output2(ind) = output2;
for each variable after the function call? function output indexing MATLAB Answers — New Questions
Help Needed: Fixing Indexing Error in MATLAB Random Name Generator Code
I am working on developing a name generator tool in MATLAB to produce random names for individuals or animals. I am inspired by the functionality of the website nameswhisperer.com and aim to create a similar tool.
I have written the following MATLAB code to generate random names:
function randomName = generateRandomName()
% Define lists of name components
firstNames = {‘Alex’, ‘Jordan’, ‘Taylor’, ‘Riley’, ‘Morgan’};
lastNames = {‘Smith’, ‘Johnson’, ‘Williams’, ‘Brown’, ‘Jones’};
% Generate random indices
firstNameIndex = randi(length(firstNames));
lastNameIndex = randi(length(lastNames));
% Construct random name
randomName = [firstNames(firstNameIndex) ‘ ‘ lastNames(lastNameIndex)];
end
% Example usage
name = generateRandomName();
disp([‘Generated Name: ‘ name]);
However, I am encountering an issue with the code. Specifically, when I run the script, I receive an error related to the way names are indexed and concatenated.
Could you help identify and correct the mistake in the code?
Thank you for your assistance!I am working on developing a name generator tool in MATLAB to produce random names for individuals or animals. I am inspired by the functionality of the website nameswhisperer.com and aim to create a similar tool.
I have written the following MATLAB code to generate random names:
function randomName = generateRandomName()
% Define lists of name components
firstNames = {‘Alex’, ‘Jordan’, ‘Taylor’, ‘Riley’, ‘Morgan’};
lastNames = {‘Smith’, ‘Johnson’, ‘Williams’, ‘Brown’, ‘Jones’};
% Generate random indices
firstNameIndex = randi(length(firstNames));
lastNameIndex = randi(length(lastNames));
% Construct random name
randomName = [firstNames(firstNameIndex) ‘ ‘ lastNames(lastNameIndex)];
end
% Example usage
name = generateRandomName();
disp([‘Generated Name: ‘ name]);
However, I am encountering an issue with the code. Specifically, when I run the script, I receive an error related to the way names are indexed and concatenated.
Could you help identify and correct the mistake in the code?
Thank you for your assistance! I am working on developing a name generator tool in MATLAB to produce random names for individuals or animals. I am inspired by the functionality of the website nameswhisperer.com and aim to create a similar tool.
I have written the following MATLAB code to generate random names:
function randomName = generateRandomName()
% Define lists of name components
firstNames = {‘Alex’, ‘Jordan’, ‘Taylor’, ‘Riley’, ‘Morgan’};
lastNames = {‘Smith’, ‘Johnson’, ‘Williams’, ‘Brown’, ‘Jones’};
% Generate random indices
firstNameIndex = randi(length(firstNames));
lastNameIndex = randi(length(lastNames));
% Construct random name
randomName = [firstNames(firstNameIndex) ‘ ‘ lastNames(lastNameIndex)];
end
% Example usage
name = generateRandomName();
disp([‘Generated Name: ‘ name]);
However, I am encountering an issue with the code. Specifically, when I run the script, I receive an error related to the way names are indexed and concatenated.
Could you help identify and correct the mistake in the code?
Thank you for your assistance! matlab, matlab code MATLAB Answers — New Questions
Using Metal cylinder rod replace rectangle shape Yagi-uda antenna design
Hi I want to ask is there any ways to change the geometry shape of antenna toolbox designing yagi antenna. The default shape is in rectangle shape, and I want it to be in cylindrical form as I want to create it physically. Is there any ways to change the shape?Hi I want to ask is there any ways to change the geometry shape of antenna toolbox designing yagi antenna. The default shape is in rectangle shape, and I want it to be in cylindrical form as I want to create it physically. Is there any ways to change the shape? Hi I want to ask is there any ways to change the geometry shape of antenna toolbox designing yagi antenna. The default shape is in rectangle shape, and I want it to be in cylindrical form as I want to create it physically. Is there any ways to change the shape? antenna, simulation, emf MATLAB Answers — New Questions
undefined function or variable: docopt
Undefined function or variable ‘docopt’.
Error in install_SplitLab (line 384)
[doccmd,options,docpath] = docoptUndefined function or variable ‘docopt’.
Error in install_SplitLab (line 384)
[doccmd,options,docpath] = docopt Undefined function or variable ‘docopt’.
Error in install_SplitLab (line 384)
[doccmd,options,docpath] = docopt splitlab1.2.1 MATLAB Answers — New Questions
Methods of Detecting and Removing Protrusions in Image
Is there any way to remove only the red shaded area of an image like the one below?
The data is a binary image and is binarized.
The image we are recognizing is basically a figure like the one on the left, so we can use bwareafilt to extract the maximum structure.
However, sometimes we get images like the one on the right. It does not mean that every time they are attached.
It would be best if we could set a threshold (if they are too close together, we recognize them as one), since the degree of attachment of the two objects varies.
We would appreciate it if you could let us know.Is there any way to remove only the red shaded area of an image like the one below?
The data is a binary image and is binarized.
The image we are recognizing is basically a figure like the one on the left, so we can use bwareafilt to extract the maximum structure.
However, sometimes we get images like the one on the right. It does not mean that every time they are attached.
It would be best if we could set a threshold (if they are too close together, we recognize them as one), since the degree of attachment of the two objects varies.
We would appreciate it if you could let us know. Is there any way to remove only the red shaded area of an image like the one below?
The data is a binary image and is binarized.
The image we are recognizing is basically a figure like the one on the left, so we can use bwareafilt to extract the maximum structure.
However, sometimes we get images like the one on the right. It does not mean that every time they are attached.
It would be best if we could set a threshold (if they are too close together, we recognize them as one), since the degree of attachment of the two objects varies.
We would appreciate it if you could let us know. image analysis, image segmentation MATLAB Answers — New Questions
How to create dynamic options in system object block mask parameters
I want to make the dropdown content of one system object parameter based on the value of another parameter. In other words, Timer 1 may support options A, B and C, while Timer 2 would only support options A and B. I can do this in a standard subsystem block mask by modifying the option parameter dropdown content on the callback for the timer parameter. MATLAB system objects only seem to support defining dropdown content for their parameters statically. Is this possible?I want to make the dropdown content of one system object parameter based on the value of another parameter. In other words, Timer 1 may support options A, B and C, while Timer 2 would only support options A and B. I can do this in a standard subsystem block mask by modifying the option parameter dropdown content on the callback for the timer parameter. MATLAB system objects only seem to support defining dropdown content for their parameters statically. Is this possible? I want to make the dropdown content of one system object parameter based on the value of another parameter. In other words, Timer 1 may support options A, B and C, while Timer 2 would only support options A and B. I can do this in a standard subsystem block mask by modifying the option parameter dropdown content on the callback for the timer parameter. MATLAB system objects only seem to support defining dropdown content for their parameters statically. Is this possible? matlab system objects MATLAB Answers — New Questions
Impact of Gripper’s Roll Angle on Reachable Poses for UR5e Robot
When I change the roll angle of the gripper, as demonstrated in my example code, the number of reachable poses varies for each roll angle. I’ve tested this with the same number of reference bodies (bodyName). The results were 411, 540, 513, and 547 reachable poses for different roll angles. I understand that this variation arises because each roll angle results in a different final configuration for the robot, affecting the GIK (Generalized Inverse Kinematics) solution. However, for a UR5e robot, this variation should not occur in real, right ? In practical use, can the UR5e achieve all 547 (assuming it’s the maximum it’s capable of reaching in this case) reachable poses for each roll angle?
for orientationIdx = 1:size(orientationsToTest,1)
for rollIdx = 1:numRollAngles
orientationsToTest(:,3) = rollAngles(rollIdx);
currentOrientation = orientationsToTest(orientationIdx,:);
targetPose = constraintPoseTarget(gripper);
targetPose.ReferenceBody = bodyName; %reference body
targetPose.TargetTransform = trvec2tform([0 0 0]) * eul2tform(currentOrientation,"XYZ");
[qWaypoints(2,:),solutionInfo] = gik_Pick(q0,targetPose);
end
endWhen I change the roll angle of the gripper, as demonstrated in my example code, the number of reachable poses varies for each roll angle. I’ve tested this with the same number of reference bodies (bodyName). The results were 411, 540, 513, and 547 reachable poses for different roll angles. I understand that this variation arises because each roll angle results in a different final configuration for the robot, affecting the GIK (Generalized Inverse Kinematics) solution. However, for a UR5e robot, this variation should not occur in real, right ? In practical use, can the UR5e achieve all 547 (assuming it’s the maximum it’s capable of reaching in this case) reachable poses for each roll angle?
for orientationIdx = 1:size(orientationsToTest,1)
for rollIdx = 1:numRollAngles
orientationsToTest(:,3) = rollAngles(rollIdx);
currentOrientation = orientationsToTest(orientationIdx,:);
targetPose = constraintPoseTarget(gripper);
targetPose.ReferenceBody = bodyName; %reference body
targetPose.TargetTransform = trvec2tform([0 0 0]) * eul2tform(currentOrientation,"XYZ");
[qWaypoints(2,:),solutionInfo] = gik_Pick(q0,targetPose);
end
end When I change the roll angle of the gripper, as demonstrated in my example code, the number of reachable poses varies for each roll angle. I’ve tested this with the same number of reference bodies (bodyName). The results were 411, 540, 513, and 547 reachable poses for different roll angles. I understand that this variation arises because each roll angle results in a different final configuration for the robot, affecting the GIK (Generalized Inverse Kinematics) solution. However, for a UR5e robot, this variation should not occur in real, right ? In practical use, can the UR5e achieve all 547 (assuming it’s the maximum it’s capable of reaching in this case) reachable poses for each roll angle?
for orientationIdx = 1:size(orientationsToTest,1)
for rollIdx = 1:numRollAngles
orientationsToTest(:,3) = rollAngles(rollIdx);
currentOrientation = orientationsToTest(orientationIdx,:);
targetPose = constraintPoseTarget(gripper);
targetPose.ReferenceBody = bodyName; %reference body
targetPose.TargetTransform = trvec2tform([0 0 0]) * eul2tform(currentOrientation,"XYZ");
[qWaypoints(2,:),solutionInfo] = gik_Pick(q0,targetPose);
end
end matlab MATLAB Answers — New Questions