https://ch.mathworks.com/matlabcentral/answers/questionsMATLAB Answers — New Questions2020-08-05T10:52:07Ztag:ch.mathworks.com,2005:Question/5753142020-08-05T05:07:11Z2020-08-05T10:52:07ZObtain the mean angle (circle mean of a file) Hi, first of all, thank you for reading me, i need something very simple but i can't find a good program to do this...
The average of wind direction data.
i am using matlab 2019a, and have all this data (for a year) and i need the average of this data (attach photo) for every row (this data are in degree, so this not regular mean is circle mean that i need) , so every 10 minutes, so in the end i want to have only one column, i am using meanangle, but i don't obtain good results. don't obtain good results.
if you can help me I would appreciate it too muchAna Sophhttps://ch.mathworks.com/matlabcentral/profile/authors/17227402tag:ch.mathworks.com,2005:Question/5747892020-08-04T06:59:35Z2020-08-05T10:51:34ZPlot a box around set of pointsDear all, I would be grateful if you can tell me how I can create a 0.5 x 0.5 box around each point that I have. I want each point to be the center of the box, in fact.
Here is the list of my points which include latitude and longitude of them.
For example:
scatter(Points.lon, Points.lat, '.') % lon is x and lat is y
Behzad Navidihttps://ch.mathworks.com/matlabcentral/profile/authors/15525777tag:ch.mathworks.com,2005:Question/5754792020-08-05T10:31:28Z2020-08-05T10:47:35ZHow to open multiple figures and combine them into a new figure Hello, I have multiple open figures. I want to create a new figure containing all the figures. How can I do this?
I tried this :
clear all
clc
%%Oppening figure
rep = 'C:\Users\ss248190\Desktop\taux_vide\Figures';
if exist(rep, 'file')~=7
error('Le dossier n''existe pas');
end
ext = '*.fig';
chemin = fullfile(rep,ext);
list = dir(chemin);
for n = 1:numel(list)
filename = fullfile(rep,list(n).name);
Fig1 = openfig(filename,'reuse');
end
Any help will be appreciated. Thanks!sanae serbouthttps://ch.mathworks.com/matlabcentral/profile/authors/14222030tag:ch.mathworks.com,2005:Question/1283812014-05-05T19:49:31Z2020-08-05T10:46:35ZHow to calculate mean wind directionHello!
I need help figuring out how to calculate mean wind direction when my data is in degrees (0-360). I just realized my current program does not take into account that the data is circular, and the mean of 355 and 5 will be 180, instead of 0. Any help is greatly appreciated! I am a beginner when it comes to MATLAB programmingJenna Mariehttps://ch.mathworks.com/matlabcentral/profile/authors/5211601tag:ch.mathworks.com,2005:Question/5751072020-08-04T17:01:06Z2020-08-05T10:46:11ZApp Slow With UIAxesHi. I'm creating apps on app designer which use components such as sliders to control a plot. When plotting on a UIAxes, there is significant delay. However, when having the app plot on a separate figure, there is no delay. Does anyone know the reason for this and if there's a way to plot on the UIAxes without the delay? Thanks.Ephraim Bryskihttps://ch.mathworks.com/matlabcentral/profile/authors/14049778tag:ch.mathworks.com,2005:Question/5746902020-08-03T22:41:41Z2020-08-05T10:40:43Zmlx file in UbuntuI create a mlx file on Ubuntu and try to save it. Then it is saved actually as a folder with matlab, metadata, and _rels folders. Why? How can one deal with them? alpedhuezhttps://ch.mathworks.com/matlabcentral/profile/authors/10930090tag:ch.mathworks.com,2005:Question/5754732020-08-05T10:27:24Z2020-08-05T10:39:25ZSearch by line nameIn a multi-level model, is it possible to get all the ouports and line names as well using command line ?Mariam Achrafhttps://ch.mathworks.com/matlabcentral/profile/authors/15643040tag:ch.mathworks.com,2005:Question/5753922020-08-05T08:09:18Z2020-08-05T10:37:13ZFinding Commented blocks programmaticallyThough find_system can include the commented blocks along with other blocks, is there any way in find_system or get_param to find only the blocks that were commented? (Both Commented-out or commented-through)
cmtd = find_system(model,'FollowLinks','on','LookUnderMasks','all','IncludeCommented','on')
I was trying to delete the commented blocks in a model.Shankar Santhoshhttps://ch.mathworks.com/matlabcentral/profile/authors/17590604tag:ch.mathworks.com,2005:Question/4364222018-12-19T01:27:51Z2020-08-05T10:31:55ZI am getting an Index in position 1 exceeds array bounds error I am getting the following index error:
Index in position 1 exceeds array bounds (must not exceed 1).
Error in L_Individual_Correlation_With_Players>DispCorr (line 36)
MeanSI1 = nanmean(RSI1(1:22,:),1);
Error in L_Individual_Correlation_With_Players (line 8)
IndPhasesDispCorr = DispCorr(IndGameDispersion,PhasesTimeStamps,PhasesDuration)
I don't understand why this error is occuring. If I run a few sample points individually, the error doesn't occur. Any help would be greatly appreciated. I have attached the sample workspace.
Here is the script:
IndPhasesDispCorr = DispCorr(IndGameDispersion,PhasesTimeStamps,PhasesDuration);
function IndDispCorr = DispCorr(IndGameDispersion,Idx,Context)
IndDispCorr = zeros(size(length(Idx)));
count = 0;
for k = 1:length(Idx)
PhaseWindow = Idx(k)+(Context(k,1)*10);
if PhaseWindow < Idx(k)
t = PhaseWindow:Idx(k);
else
t = Idx(k):PhaseWindow;
end
M = IndGameDispersion(t,:);
RSI1 = corrcoef([M(:,1:22) nanmean(M(:,1:22),2)],'rows','pairwise');
Rx1 = corrcoef([M(:,23:44) nanmean(M(:,23:44),2)],'rows','pairwise'); %Last column is centroid coordinates
Ry1 = corrcoef([M(:,45:66) nanmean(M(:,23:44),2)],'rows','pairwise');
RSI1(RSI1 == 1) = NaN;
Rx1(Rx1 == 1) = NaN;
Ry1(Ry1 == 1) = NaN;
MeanSI1 = nanmean(RSI1(1:22,:),1);
MeanRx1 = nanmean(Rx1(1:22,:),1);
MeanRy1 = nanmean(Ry1(1:22,:),1);
CorrN = [MeanSI1,nanmean(MeanSI1(1:22),2),MeanRx1,nanmean(MeanRx1(1:22),2),MeanRy1,nanmean(MeanRy1(1:22),2)];
count = count + 1;
IndDispCorr(count,1:72) = CorrN;
end
end
William Sheehanhttps://ch.mathworks.com/matlabcentral/profile/authors/12660987tag:ch.mathworks.com,2005:Question/5754762020-08-05T10:29:39Z2020-08-05T10:30:04ZIntegrate kernel probability distribution functionDear MatLab comunity,
I have a distribution of dihedral angles over a number of frames from a simulation. (attached is the data file)
M2OH6 = load('OH6p.txt');
y6 = M2OH6(:,2);
title('Probability density function of M2-OH6');
nbins = 100;
rng('default')
[f3,y6i] = ksdensity(y6);
plot(y6i,f3,'Color','r','Linewidth',1)
xlabel('\theta (deg)');
ylabel('P(\theta) (deg^{-1})');
xticks(-360:60:360);
yticks(0:0.01:0.045);
axis([-360 360 0 0.045]);
pbaspect([1 1 1]);
So I need to know what is the percentage of the states falling in the range between let's say 0:120 degrees (theta), 120:180 degrees and 180:-120.
In such case I was thinking that maybe I should integrate the kernel density function in such ranges but I'm not sure how to do it and obviously I'm a very beginner in MatLab.
Is there anybody who could suggest me a way?
Thanks in advance,
AlexAlessandro Rudahttps://ch.mathworks.com/matlabcentral/profile/authors/18976617tag:ch.mathworks.com,2005:Question/5339432020-05-26T10:02:49Z2020-08-05T10:27:20ZSetting a Pivot year when creating Datenum matrixHi,
I need to create a variable that is hourly values for the month of January 2017, measured as number of days since 00:00 01.01.2017.
starttime = datenum(2017, 1, 1, 0, 0, 0);
endtime = datenum(2017, 2, 1, 0, 0, 0);
t = datenum(2017, 1, 1,[0:(endtime-starttime)*24-1].',0,0);
I've written the above to get my fractional day values, but when I add a pivot year (2017) to the end of the line for t, I get this error: "Error using datenum: Too many input arguements". I also get this error if I add 2017 to the end of the starttime and endtime lines.
I know I could just redefine t as [0 : (1/24): 31] in this instance, but as I will have to repeat this for every month in 2017 and 2018, I don't think this is sustainable. Victoria Dutchhttps://ch.mathworks.com/matlabcentral/profile/authors/16610742tag:ch.mathworks.com,2005:Question/5751522020-08-04T18:40:24Z2020-08-05T10:24:30ZI need help solving a system of differential equations. The equations are given below, in matrix form. The problem that I'm having is regarding the fact that I have time dependant elements in the matrices.Jelena Kresojahttps://ch.mathworks.com/matlabcentral/profile/authors/12912861tag:ch.mathworks.com,2005:Question/5747472020-08-04T02:35:39Z2020-08-05T10:23:53ZDraw 3 D from 4 data setsHow I can draw 3 D from the these data to get graph as atteched?
x1 = [60 65 70 75 80 85 90 95]
y 1= [717.7443511 450.2110549 315.3203173 281.0355881 310.2619146 367.5904781 425.4810863 466.5103523]
x2 = [32 34 36 38 40 42 44]
y2 = [2461.769179 2698.95206 2893.41954 2863.069124 2539.331353 1964.921629 1246.066407]Asma A Bder Muhmedhttps://ch.mathworks.com/matlabcentral/profile/authors/18387297tag:ch.mathworks.com,2005:Question/5749332020-08-04T12:21:55Z2020-08-05T10:20:36ZHow can solve constrait optimization?Hi everyone, I have constrait optimizatıon problem. I am trying to maxımize x, y and z. And some of my constrait are like that
0.2<=y
0.2<= x
0.2<=z<=2
x+y<=z
How can ı express the lass constrait ın matlab? Using A, b ,x0Sinem Senelhttps://ch.mathworks.com/matlabcentral/profile/authors/19112931tag:ch.mathworks.com,2005:Question/5753562020-08-05T06:54:48Z2020-08-05T10:19:48ZHow to use ode15s with a constant that varies by two parameters?I am using Matlab to simulate protein electrokinetics. Part of the complexity of simulating a system is that some of the constants vary by a time independent d parameter and a time dependent parameter. I have been able to incorporate the time dependency of the constant correctly, however, the time independent parameter is stumping me. I tried to define the anonymous function I used for the time dependent part as having two variables and then giving it the values I want the d parameter to go through and then taking the average, but this is not giving me the desired results. The code:
Enfcn = @(t) Ei + v * t;
kred = @(t, d) 225000 * exp(-d) * exp(((-a * F)/(R * T)) * (Enfcn(t) - Eo));
kox = @(t, d) 225000 * exp(-d)* exp((((1-a) * F)/(R * T)) * (Enfcn(t) - Eo));
C0 = [0.01, 0, 0, 0, 0, 0, 1e9, 0];
options = odeset('RelTol', 1e-9, 'AbsTol', 1e-10);
[Time, Concentrations] = ode15s(@(t, C) mechanism(t, C, kred, kox), tspan, C0, options);
function dC = mechanism(t, C, kred, kox)
x = 4:0.1:12;
% Rate Laws
dNiII = -y(1)*y(7) + y(3) + y(2)*y(7);
dNiIISH = -y(2) + y(2)*y(7) - kred(t, x)*y(2) + kox(t, x)*y(3);
dNiISH = kred(t, x)*y(2) - kox(t, x)*y(3) - y(3);
de = -kred(t, x)*(y(2) + y(5)) + kox(t, x)*(y(3) + y(6));
dNiIIIH = y(3) - kred(t, x)*y(5) + kox(t, x)*y(6);
dNiIIH = kred(t, x)*y(5) - kox(t, x)*y(6) - y(7)*y(8);
dH = -y(6)*y(7) - y(1)*y(7) + kb*y(6);
dH2 = y(6)*y(7);
% Assign Output Variables
dC(1,:) = mean(dNiII);
dC(2,:) = mean(dNiIISH);
dC(3,:) = mean(dNiISH);
dC(4,:) = mean(dNiIIIH);
dC(5,:) = mean(dNiIIH);
dC(6,:) = mean(de)*(96485.33289/1e9);
dC(7,:) = mean(dH);
dC(8,:) = mean(dH2);
end
I am intending for the differential equations to be solved for time, and then be solved as a function of the d parameter. I was thinking of using nested functions but I am not sure how to execute that. At any rate, for a particular time, the constants kred and kox should have say 10 values based on the d parameters. I want for the system to be solved with one constant of d for time and then all the solutions for all the different d values are averaged, but the above code is not accomplishing what I hoped. Thanks for any help in advance.Riley Steinhttps://ch.mathworks.com/matlabcentral/profile/authors/18156630tag:ch.mathworks.com,2005:Question/5014552020-01-22T13:03:22Z2020-08-05T10:18:59Zhow to send multiple integer values from matlab to arduino ide?i have established connection between arduino ide and matlab,how can i send multiple integer values as an array of list from matlab to arduino.
Shlok Sharmahttps://ch.mathworks.com/matlabcentral/profile/authors/14731714tag:ch.mathworks.com,2005:Question/5754672020-08-05T09:50:34Z2020-08-05T10:18:41ZHow to find the gradient of a parameter which is not direct solution of a functionHi,
I have a system of 2D nonlilnear system (f(x,y)) where I use fsolve to solve them for x and y. Then x and y are used in least square sense to obtain some parameters (alpha). I need to find the gradient of the alpha, is there any way to find the finite difference this?
Thanks,
SyedSyed AWMhttps://ch.mathworks.com/matlabcentral/profile/authors/19134069tag:ch.mathworks.com,2005:Question/5754612020-08-05T09:44:28Z2020-08-05T10:15:40ZIf statement for input valueI want the user to give a number, depending on that number gives the user a number of questions to answer
ex
n = input('how many ingredients do you have');
%%FOOD INPUT
if n =1
a = input('Type code of Ingrediant #1: ');
A = input('Type quantity of Ingrediant #1: ');
end
if n =2
a = input('Type code of Ingrediant #1: ');
A = input('Type quantity of Ingrediant #1: ');
b= input('Type code of Ingrediant #2: ');
B= input('Type quantity of Ingrediant #2: ');
end
etc..
Jarren Berdalhttps://ch.mathworks.com/matlabcentral/profile/authors/14898914tag:ch.mathworks.com,2005:Question/5754372020-08-05T09:20:10Z2020-08-05T10:14:10ZIs there a way to select a variable from a drown down menu rather than a string?I want to have something like this:
x = 1;
y = 2;
z = 3;
% drop down menu options are x, y, or z.
dropdownValue = x;
disp(dropdownValue);
dropdownValue
= 1
what I actually get is:
x = 1;
y = 2;
z = 3;
% drop down menu options are x, y, or z.
dropdownValue = 'x';
disp(dropdownValue);
dropdownValue
= x
I'm struggling to describe it very well but hope this kind of sudo-code helps! Eddie Martinhttps://ch.mathworks.com/matlabcentral/profile/authors/18973663tag:ch.mathworks.com,2005:Question/5750082020-08-04T14:35:49Z2020-08-05T10:11:21ZFirst Order Differential EquationI need to solve the below first ODE with a set time step say (Delt = 0.01s) and from 0 - 20s. Initial condiitons Y0 = [ 0 ; 0 ; 0 ]
dof = 3; %Three Story
I = 1.5796*10^(-2); %m^4
E = 0.209*10^9; %kN/m^2
m = 500000; %kg
k = 849116255; %N/m
m1 = 2*m;
m2 = 2*m;
m3 = m;
k1 = 3*k;
k2 = 3*k;
k3 = 2*k;
M = [ m1 0 0 ; 0 m2 0 ; 0 0 m3 ]; %Mass Matrix
K = [(k1+k2) -k 0 ; -k2 (k2+k3) -k3 ; 0 -k3 k3 ]; %Stiffness Matrix
C = [ 7 -3 0 ; -3 3.2 -1.4 ; 0 -1.4 1.4 ]*10^5; %Damping Matrix
o = [ 0 0 0 ; 0 0 0 ; 0 0 0 ]; %Zero Matrix
A = [ M o ; o eye(dof) ]
B = [ o K ; -eye(dof) o ]
P = 2*sin(4*(4*pi*t))
ft = [P ; 0 ; 0]
Yt+1 = Yt+ delt(inv(A)*(ft-B*Yt))
Once this has been computed, how does one store the results for each itteration of time and subsequently plot it?Christopher Wijnberghttps://ch.mathworks.com/matlabcentral/profile/authors/13304463tag:ch.mathworks.com,2005:Question/5754402020-08-05T09:20:23Z2020-08-05T10:06:25ZHow do I go about plotting points from ODE45 with this?I have been trying to use ODE45 to solve the linearised model, my aim is to plot values of y and x displacement but the code does not seem to churn out any right answers. The attached images are the equations I am given to work around with. Are my ODE45 parameters wrong? Any advice would help a lot!
my function is as follows
function dydx = odefcn(x, y, a, v)
dydx = zeros(2, 1);
dydx(1) = y(2);
dydx(2) = a/v^2;
%========================= MAIN CODE ===========================%
% Get launch angle (theta) from user, then get initial x and y coordinates
% Constants are VELOCITY (v), N, DESIGNATED TIME (Td)
% Variables are x and y
% LOS, a, L are always changing, so need to INCLUDE THEM IN A LOOP
% Output will be x and y, ALSO ALWAYS CHANGING
%======================= Get input from user =============================%
theta0 = input('Please input launch angle in degrees: ');
x0 = input('Please enter initial x coordinates: ');
y0 = input('Please enter initial y coordinates: ');
%=========================== Constants ===================================%
v = 300;
N = 3; % Proportionality constant
Td = 40; % designated impact time
targetx= 50; targety = 50; % set targetcoordinates
Rgo_x = targetx - x0;
Rgo_y = targety - y0;
theta = theta0;
xspan = [x0 targetx];
yspan = [y0 targety];
IC = [0 theta0];
x=x0; y=y0;
while Rgo_y ~= 0 & Rgo_x ~= 0
Rgo = sqrt(Rgo_x^2 + Rgo_y^2);
LOS = -(Rgo_y/(Rgo^2));
Tgo = (1+ (theta-acosd(Rgo_x/Rgo))/10)*(Rgo/v);
a = N*v*LOS - (60*v^5*(Td-Tgo))/(N*v*LOS*(Rgo^3));
theta = a*(Rgo_x)/v^2 + theta;
[x, y] = ode45(@(x, y)odefcn(x, y, a, v), xspan, yspan, IC);
Rgo_x = targetx - x;
Rgo_y = targety - y;
end
%================ Plot x and Y values wrt to angle changes ===============%
figure
grid on
plot(x, y, 'o')
xlabel('x displacement (m)');
ylabel('y displacement (m)');
Ethan Wong Yew Hoehttps://ch.mathworks.com/matlabcentral/profile/authors/19006870tag:ch.mathworks.com,2005:Question/5749542020-08-04T13:29:38Z2020-08-05T10:04:35ZHow parentheses effects multiplication with pi ?Hi,
I am trying to generate sine wave. I am usning following two code lines. But they are slightly different (about e-15). Why is it happenning ? What is the differences of two lines;
f0=5e2;
fs=500e2;
len=3e3;
dt=1/fs;
t=0:dt:(len-1);
sing1= sin (2*pi*f0*t);
sing2= sin(2*pi*(f0*t));
isequal(sing1,sing2)
Thanks for your help,Emre Dorukhttps://ch.mathworks.com/matlabcentral/profile/authors/6113648tag:ch.mathworks.com,2005:Question/245022011-12-21T15:40:32Z2020-08-05T09:58:36Zspeech signal from Microphone USBhi , i have question . In matlab , can i take online speech signal from Microphone USB and use it in my code at same time ??
can do that ?????
hajerhttps://ch.mathworks.com/matlabcentral/profile/authors/3117797tag:ch.mathworks.com,2005:Question/5720382020-07-29T03:10:24Z2020-08-05T09:56:35ZI don't know how to interpret this ANN classification code.I constructed following code by utilizing other's code and this code is considerably operated well. I got the 5 confusion matrix after running the code. but I can't interpret this result and code. Do five confusion matrix mean the individual result of K-Fold cross validation? I don't know why 5 confusion matrix were shown. and above all, Do my code is correctly wrotten? I use 6 inputs and 2 outputs for 32 samples.
rng(3); % initialize the RNG to the same state before training to obtain reproducibility
% conversion of table to matrix after loading .csv file.
input = table2array(inputs);
target = table2array(targets);
% hidden layers
hiddenLayerSize = 10;
net = patternnet(hiddenLayerSize);
% Choose the Divide Function
net.divideFcn = 'divideind';
% Choose the Performance Function
net.trainFcn = 'trainscg'
% K-Fold cross validation
k = 5;
cvFolds = crossvalind('Kfold', size(target,2), k);
for i = 1:k
net = configure(net, input, target);
testIdx = (cvFolds == i);
trainIdx = ~testIdx;
trInd = find(trainIdx)
tstInd = find(testIdx)
net.trainParam.epochs = 100;
net.divideParam.trainInd = trInd
net.divideParam.testInd = tstInd
% Performance Function
net.performFcn = 'mse'; % Mean squared error
% Train the network
[net, tr] = train(net,input,target);
% test using test instances
output = net(input);
errors = gsubtract(target, output);
performance = perform(net,target,output)
% Recalculate Training, Validation and Test Performance
trainTargets = target .* tr.trainMask{1};
testTargets = target .* tr.testMask{1};
trainPerformance = perform(net,trainTargets,output)
testPerformance = perform(net,testTargets,output)
test(k)=testPerformance;
% Plot confusion
save net
figure, plotconfusion(target,output)
end
accuracy=mean(test);
% View the Network
view(net)
ples.
JUN BEOM JEONhttps://ch.mathworks.com/matlabcentral/profile/authors/17000851tag:ch.mathworks.com,2005:Question/5754582020-08-05T09:38:49Z2020-08-05T09:56:32ZHow to convert a matrix to a table with headingsHello all, I am new to matlab and I have created this matrix from data by using various formulas and now i want to add heading to it. Can someone please guide me how to do this. It is a 7*9 matrix
X =
294.1560 230.5800 63.5760 2.0194 1.7763 -0.9084 -293.4180 -90.2551 266.7389
328.5000 230.5800 97.9200 2.1296 1.7763 -0.7982 -257.8234 -89.8860 265.8574
367.6640 230.5800 137.0840 2.2419 1.7763 -0.6859 -221.5505 -89.5398 269.0948
421.0700 230.5800 190.4900 2.3771 1.7763 -0.5507 -177.8809 -89.1509 279.2200
482.5700 230.5800 251.9900 2.5131 1.7763 -0.4147 -133.9529 -88.8135 297.1294
553.5940 230.5800 323.0140 2.6502 1.7763 -0.2776 -89.6696 -88.4916 324.1920
641.4000 230.5800 410.8200 2.7978 1.7763 -0.1300 -41.9948 -88.1127 364.7022
Niraj Pansarahttps://ch.mathworks.com/matlabcentral/profile/authors/17989539tag:ch.mathworks.com,2005:Question/5754702020-08-05T09:55:50Z2020-08-05T09:55:50ZChange data tip so it shows temperatureI have created a thermal model using matlab pde, and it works well. However, when opening the model in a figure window, the data tip function only shows X, Y, and Z data. I've tried looking for a way to change this so it shows the temperature at certain points (e.g when clicking anywhere on the model, it will show the temperature). Is there anyway I can do this? I feel like this should be intergrated somewhere in the window. Below is my code if needed.
u = symunit;
SIUnits = baseUnits('SI');
gm = multicuboid([2 2.1 2.7 3.2 20],[2.1 2.2 2.7 3.2 20],1.55);
thermalmodel = createpde('thermal','transient');
thermalmodel.Geometry = gm
pdegplot(thermalmodel,'CellLabels','on','FaceAlpha',0.5);
figure('Position',[10,10,800,400]);
subplot(1,2,1)
pdegplot(thermalmodel,'FaceAlpha',0.25,'CellLabel','on')
title('Geometry with Cell Labels')
subplot(1,2,2)
pdegplot(thermalmodel,'FaceAlpha',0.25,'FaceLabel','on')
title('Geometry with Face Labels')
generateMesh(thermalmodel,'Hmax',1);
Water at 30 degrees C
thermalProperties(thermalmodel,'ThermalConductivity',0.616,'SpecificHeat',4184,'MassDensity',997,'Cell',1);
304 stainless steel
thermalProperties(thermalmodel,'ThermalConductivity',16.2,'SpecificHeat',500,'MassDensity',8000,'Cell',2);
Soapstone
thermalProperties(thermalmodel,'ThermalConductivity',6.4,'SpecificHeat',980,'MassDensity',2980,'Cell',3);
Concrete
thermalProperties(thermalmodel,'ThermalConductivity',1.2,'SpecificHeat',880,'MassDensity',2400,'Cell',4);
Soil
thermalProperties(thermalmodel,'ThermalConductivity',6.4,'SpecificHeat',750,'MassDensity',2434,"Cell",5);
thermalmodel.StefanBoltzmannConstant = 5.670373E-8;
thermalBC(thermalmodel,'Temperature',353.15,'Face',[1 2 3 4 5 6]);
thermalIC(thermalmodel,277.65,'Cell',5);
thermalIC(thermalmodel,295.15,'Cell',1);
thermalIC(thermalmodel,293.15,'Cell',[2 3 4]);
thermalBC(thermalmodel,'AmbientTemperature',350.15,"Emissivity",0.38,"Face",[7 8 9 10 11 12]);
thermalBC(thermalmodel,'AmbientTemperature',313.15,'Emissivity',0.94,'Face',[19 20 21 22 23 24]);
thermalBC(thermalmodel,'HeatFlux',-4019.4,'Face',[7 8 9 10 11 12]);
thermalBC(thermalmodel,'HeatFlux',-240.67,'Face',[13 14 15 16 17 18]);
generateMesh(thermalmodel);
tlist = 10:100:86400;
Model after 24 hours (86400 seconds)
thermalresults = solve(thermalmodel,tlist);
T = thermalresults.Temperature;
pdeplot3D(thermalmodel,'ColorMapData',thermalresults.Temperature(:,end));Alun Owenhttps://ch.mathworks.com/matlabcentral/profile/authors/18700489tag:ch.mathworks.com,2005:Question/5749212020-08-04T12:03:15Z2020-08-05T09:53:00Zhow to solve the following equation to get lambda values from it?modulus([2 -1; -1 2]-λ[1 0; 0 1])=0
please help me. thanks.Venkata Rama Krishna Gonahttps://ch.mathworks.com/matlabcentral/profile/authors/17745533tag:ch.mathworks.com,2005:Question/5754642020-08-05T09:50:20Z2020-08-05T09:50:20ZHow to display a calculation result into a Text Edit Filed using App DesignerHello,
As I am new to MATLAB and App Designer, I have the following problem :
I have a button with a callback function, where I am doing my calculations. In the end I have some results I would like to display in the TexEdit Field.
avgDiff = mean(diff(timestamp')); %checking the acquisiton rate
fprintf('The average timestamp diff is %.3f\n', avgDiff)
Sync_rate = (nr.framescaptured/nr.frames logged) * 100 ;
fprintf('The synchronization rate is: %.2f\n', Sync_rate )
How can I write in the end of the function that it displays these values? I have added this in the end of my function and I would like to display the numerical values taken from the calculations.
app.status(end+1,1) = {'Sync rate is... and then to display : "Avg timestamp diff is"'};
set(app.StatusWindowTextArea,'Value',app.status)
set(app.StatusColour,'Background',[0 1 0])
end
pause(1)
Thank you in advance! Maluhttps://ch.mathworks.com/matlabcentral/profile/authors/15376350tag:ch.mathworks.com,2005:Question/5753982020-08-05T08:24:58Z2020-08-05T09:49:45Zplotting for every single loopHi everyone.
I got this code and I have a question about it. Is it work for every single "v"? like 1, 2 ,3 ,4 .......
If not how can I make it for every "v" ?
N=45;
teta=0:0.02:5*pi;
y=zeros(10,length(teta));
x=zeros(size(teta));
for v=1:2:30
x=x+(0.085*N/pi)*sin(v*teta)/v;
y((v+1)/2,:)=x;
end
plot(teta,x)Ali Roshanzamirhttps://ch.mathworks.com/matlabcentral/profile/authors/8895006tag:ch.mathworks.com,2005:Question/3980782018-04-29T18:09:13Z2020-08-05T09:49:02Z3D printing using MATLABSir,
Is that possible to code a 3d printer using MATLAB having raspberry pi as micro-controller?
If yes, please brief me regarding that; also tell about conversion of STEP or STL file to axis points in printer
With Regards,
Rajbir Singh Rajbir Singhhttps://ch.mathworks.com/matlabcentral/profile/authors/9632950tag:ch.mathworks.com,2005:Question/2320422015-08-02T10:47:32Z2020-08-05T09:46:22Zis there a matlab code for engine block of sim-driveline under simulink-matlab?i want to edit and customize the engine and variable ratio block of simdriveline under simulink according to my needs. is there a matlab code available for it in which i can make changes fore the same? akash mitrahttps://ch.mathworks.com/matlabcentral/profile/authors/6741611tag:ch.mathworks.com,2005:Question/5752572020-08-05T01:23:34Z2020-08-05T09:41:21ZDifferent Scales on same plotAttached is the image of a plot I'm willing to generate.
How to show different X Y-axis scales locally to a same plot as shown in figure.
Thank you in advance.Dhirendu Somanihttps://ch.mathworks.com/matlabcentral/profile/authors/9053052tag:ch.mathworks.com,2005:Question/5754222020-08-05T08:55:46Z2020-08-05T09:40:40ZHow can I assign strings from array to variable name from another array with same size?There are two arrays with the same size. Bothe arrays are filled with strings. The target is to use the strings from the first array as variable names and the strings from the other array as values in form of string. This means to assign first string from the other array to the first string from the first array and the second string from the other array to the second string from first array.
Target as example:
calbelength = long
cablecrosssection = small
fuseboxname = FuseBox2
Matlab Code:
Matrix_parameter_string = ["calbelength","cablecrosssection","fuseboxname"]
Matrix_value_string = ["long","small","FuseBox2"]
[line,coloumn] = size(Matrix_parameter_string)
p = coloumn;
for t = 1:p
eval(fprintf('%s=%s',Matrix_parameter_string(1,t),Matrix_value_string(1,t))); % Assign value to parameter name
end
Matlab shows following error in command window:
calbelength=longError using eval
Must be a string scalar or character vector.
Error in Untitled (line 6)
eval(fprintf('%s=%s',Matrix_parameter_string(1,t),Matrix_value_string(1,t))); % Assign value to parameter name
By the way, if the values are double instead string. This would be the solution:
for t = 1:p
eval(sprintf('%s=%d;',Matrix_parameter_string(1,t),Matrix_value_double(1,t))); % Assign value to parameter name
endRobinhttps://ch.mathworks.com/matlabcentral/profile/authors/19133558tag:ch.mathworks.com,2005:Question/5749122020-08-04T11:45:25Z2020-08-05T09:36:30ZHow to improve performances in solving ODEs?I'm studying a quarter car model and my aim is to introduce some of the nonlinearities typical of a real suspension, because I want to realize a model which is closer to reality than the classical one. What I've done so far is to introduce an elastic element composed by a spring and two bump stops acting in parallel and which is described by two polynomials in jounce and rebound. Then I used the same method to describe an asymmetric damper and in the end I defined a condition which introduce the possibility for the unsprung mass to lose contact with the ground. The result is the code written
function f = solve(tspan,y)
load Data M m kt
load MollaNonLineare kst1 kst2 kst3 kst4 kst5 kst6 kst7 ksh1 ksh2 ksh3 ksh4 ksh5 ksh6 ksh7
load CoeffAmmo csh1 csh2 csh3 csh4 csh5 csh6 csh7 cst1 cst2 cst3 cst4 cst5 cst6 cst7
cc = 0;
g = 9.81;
h = 0.01;
f = zeros(4,1);
f(1) = y(2);
if (y(1) - y(3))>0 && (y(2) - y(4))>=0
f(2) = (- csh7*(y(2) - y(4)) - csh6*(y(2) - y(4))^2 - csh5*(y(2) - y(4))^3 - csh4*(y(2) - y(4))^4 - csh3*(y(2) - y(4))^5 - csh2*(y(2) - y(4))^6 - csh1*(y(2) - y(4))^7 - cc*sign(y(2) - y(4)) - kst7*(y(1) - y(3)) - kst6*(y(1) - y(3))^2 - kst5*(y(1) - y(3))^3 - kst4*(y(1) - y(3))^4 - kst3*(y(1) - y(3))^5 - kst2*(y(1) - y(3))^6 - kst1*(y(1) - y(3))^7)/M;
elseif (y(1) - y(3))>0 && (y(2) - y(4))<0
f(2) = (- cst7*(y(2) - y(4)) - cst6*(y(2) - y(4))^2 - cst5*(y(2) - y(4))^3 - cst4*(y(2) - y(4))^4 - cst3*(y(2) - y(4))^5 - cst2*(y(2) - y(4))^6 - cst1*(y(2) - y(4))^7 - cc*sign(y(2) - y(4)) - kst7*(y(1) - y(3)) - kst6*(y(1) - y(3))^2 - kst5*(y(1) - y(3))^3 - kst4*(y(1) - y(3))^4 - kst3*(y(1) - y(3))^5 - kst2*(y(1) - y(3))^6 - kst1*(y(1) - y(3))^7)/M;
elseif (y(1) - y(3))<0 && (y(2) - y(4))>=0
f(2) = (- csh7*(y(2) - y(4)) - csh6*(y(2) - y(4))^2 - csh5*(y(2) - y(4))^3 - csh4*(y(2) - y(4))^4 - csh3*(y(2) - y(4))^5 - csh2*(y(2) - y(4))^6 - csh1*(y(2) - y(4))^7 - cc*sign(y(2) - y(4)) - ksh7*(y(1) - y(3)) - ksh6*(y(1) - y(3))^2 - ksh5*(y(1) - y(3))^3 - ksh4*(y(1) - y(3))^4 - ksh3*(y(1) - y(3))^5 - ksh2*(y(1) - y(3))^6 - ksh1*(y(1) - y(3))^7)/M;
else
f(2) = (- cst7*(y(2) - y(4)) - cst6*(y(2) - y(4))^2 - cst5*(y(2) - y(4))^3 - cst4*(y(2) - y(4))^4 - cst3*(y(2) - y(4))^5 - cst2*(y(2) - y(4))^6 - cst1*(y(2) - y(4))^7 - cc*sign(y(2) - y(4)) - ksh7*(y(1) - y(3)) - ksh6*(y(1) - y(3))^2 - ksh5*(y(1) - y(3))^3 - ksh4*(y(1) - y(3))^4 - ksh3*(y(1) - y(3))^5 - ksh2*(y(1) - y(3))^6 - ksh1*(y(1) - y(3))^7)/M;
end
f(3) = y(4);
if tspan<1 && (y(1) - y(3))>0 && (y(2) - y(4))>=0
f(4) = (csh7*(y(2) - y(4)) + csh6*(y(2) - y(4))^2 + csh5*(y(2) - y(4))^3 + csh4*(y(2) - y(4))^4 + csh3*(y(2) - y(4))^5 + csh2*(y(2) - y(4))^6 + csh1*(y(2) - y(4))^7 + cc*sign(y(2) - y(4)) + kst7*(y(1) - y(3)) + kst6*(y(1) - y(3))^2 + kst5*(y(1) - y(3))^3 + kst4*(y(1) - y(3))^4 + kst3*(y(1) - y(3))^5 + kst2*(y(1) - y(3))^6 + kst1*(y(1) - y(3))^7 - kt*y(3))/m;
elseif tspan<1 && (y(1) - y(3))>0 && (y(2) - y(4))<0
f(4) = (cst7*(y(2) - y(4)) + cst6*(y(2) - y(4))^2 + cst5*(y(2) - y(4))^3 + cst4*(y(2) - y(4))^4 + cst3*(y(2) - y(4))^5 + cst2*(y(2) - y(4))^6 + cst1*(y(2) - y(4))^7 + cc*sign(y(2) - y(4)) + kst7*(y(1) - y(3)) + kst6*(y(1) - y(3))^2 + kst5*(y(1) - y(3))^3 + kst4*(y(1) - y(3))^4 + kst3*(y(1) - y(3))^5 + kst2*(y(1) - y(3))^6 + kst1*(y(1) - y(3))^7 - kt*y(3))/m;
elseif tspan<1 && (y(1) - y(3))<0 && (y(2) - y(4))>=0
f(4) = (csh7*(y(2) - y(4)) + csh6*(y(2) - y(4))^2 + csh5*(y(2) - y(4))^3 + csh4*(y(2) - y(4))^4 + csh3*(y(2) - y(4))^5 + csh2*(y(2) - y(4))^6 + csh1*(y(2) - y(4))^7 + cc*sign(y(2) - y(4)) + ksh7*(y(1) - y(3)) + ksh6*(y(1) - y(3))^2 + ksh5*(y(1) - y(3))^3 + ksh4*(y(1) - y(3))^4 + ksh3*(y(1) - y(3))^5 + ksh2*(y(1) - y(3))^6 + ksh1*(y(1) - y(3))^7 - kt*y(3))/m;
elseif tspan<1 && (y(1) - y(3))<0 && (y(2) - y(4))<0
f(4) = (cst7*(y(2) - y(4)) + cst6*(y(2) - y(4))^2 + cst5*(y(2) - y(4))^3 + cst4*(y(2) - y(4))^4 + cst3*(y(2) - y(4))^5 + cst2*(y(2) - y(4))^6 + cst1*(y(2) - y(4))^7 + cc*sign(y(2) - y(4)) + ksh7*(y(1) - y(3)) + ksh6*(y(1) - y(3))^2 + ksh5*(y(1) - y(3))^3 + ksh4*(y(1) - y(3))^4 + ksh3*(y(1) - y(3))^5 + ksh2*(y(1) - y(3))^6 + ksh1*(y(1) - y(3))^7 - kt*y(3))/m;
elseif tspan>=1 && y(3) - h < (M+m)*g/kt && (y(1) - y(3))>0 && (y(2) - y(4))>=0
f(4) = (kt*h + csh7*(y(2) - y(4)) + csh6*(y(2) - y(4))^2 + csh5*(y(2) - y(4))^3 + csh4*(y(2) - y(4))^4 + csh3*(y(2) - y(4))^5 + csh2*(y(2) - y(4))^6 + csh1*(y(2) - y(4))^7 + cc*sign(y(2) - y(4)) + kst7*(y(1) - y(3)) + kst6*(y(1) - y(3))^2 + kst5*(y(1) - y(3))^3 + kst4*(y(1) - y(3))^4 + kst3*(y(1) - y(3))^5 + kst2*(y(1) - y(3))^6 + kst1*(y(1) - y(3))^7 - kt*y(3))/m;
elseif tspan>=1 && y(3) - h < (M+m)*g/kt && (y(1) - y(3))>0 && (y(2) - y(4))<0
f(4) = (kt*h + cst7*(y(2) - y(4)) + cst6*(y(2) - y(4))^2 + cst5*(y(2) - y(4))^3 + cst4*(y(2) - y(4))^4 + cst3*(y(2) - y(4))^5 + cst2*(y(2) - y(4))^6 + cst1*(y(2) - y(4))^7 + cc*sign(y(2) - y(4)) + kst7*(y(1) - y(3)) + kst6*(y(1) - y(3))^2 + kst5*(y(1) - y(3))^3 + kst4*(y(1) - y(3))^4 + kst3*(y(1) - y(3))^5 + kst2*(y(1) - y(3))^6 + kst1*(y(1) - y(3))^7 - kt*y(3))/m;
elseif tspan>=1 && y(3) - h < (M+m)*g/kt && (y(1) - y(3))<0 && (y(2) - y(4))>=0
f(4) = (kt*h + csh7*(y(2) - y(4)) + csh6*(y(2) - y(4))^2 + csh5*(y(2) - y(4))^3 + csh4*(y(2) - y(4))^4 + csh3*(y(2) - y(4))^5 + csh2*(y(2) - y(4))^6 + csh1*(y(2) - y(4))^7 + cc*sign(y(2) - y(4)) + ksh7*(y(1) - y(3)) + ksh6*(y(1) - y(3))^2 + ksh5*(y(1) - y(3))^3 + ksh4*(y(1) - y(3))^4 + ksh3*(y(1) - y(3))^5 + ksh2*(y(1) - y(3))^6 + ksh1*(y(1) - y(3))^7 - kt*y(3))/m;
elseif tspan>=1 && y(3) - h < (M+m)*g/kt && (y(1) - y(3))<0 && (y(2) - y(4))<0
f(4) = (kt*h + cst7*(y(2) - y(4)) + cst6*(y(2) - y(4))^2 + cst5*(y(2) - y(4))^3 + cst4*(y(2) - y(4))^4 + cst3*(y(2) - y(4))^5 + cst2*(y(2) - y(4))^6 + cst1*(y(2) - y(4))^7 + cc*sign(y(2) - y(4)) + ksh7*(y(1) - y(3)) + ksh6*(y(1) - y(3))^2 + ksh5*(y(1) - y(3))^3 + ksh4*(y(1) - y(3))^4 + ksh3*(y(1) - y(3))^5 + ksh2*(y(1) - y(3))^6 + ksh1*(y(1) - y(3))^7 - kt*y(3))/m;
elseif tspan>=1 && y(3) - h > (M+m)*g/kt && (y(1) - y(3))>0 && (y(2) - y(4))>=0
f(4) = (csh7*(y(2) - y(4)) + csh6*(y(2) - y(4))^2 + csh5*(y(2) - y(4))^3 + csh4*(y(2) - y(4))^4 + csh3*(y(2) - y(4))^5 + csh2*(y(2) - y(4))^6 + csh1*(y(2) - y(4))^7 + cc*sign(y(2) - y(4)) + kst7*(y(1) - y(3)) + kst6*(y(1) - y(3))^2 + kst5*(y(1) - y(3))^3 + kst4*(y(1) - y(3))^4 + kst3*(y(1) - y(3))^5 + kst2*(y(1) - y(3))^6 + kst1*(y(1) - y(3))^7 - (M + m)*g)/m;
elseif tspan>=1 && y(3) - h > (M+m)*g/kt && (y(1) - y(3))>0 && (y(2) - y(4))<0
f(4) = (cst7*(y(2) - y(4)) + cst6*(y(2) - y(4))^2 + cst5*(y(2) - y(4))^3 + cst4*(y(2) - y(4))^4 + cst3*(y(2) - y(4))^5 + cst2*(y(2) - y(4))^6 + cst1*(y(2) - y(4))^7 + cc*sign(y(2) - y(4)) + kst7*(y(1) - y(3)) + kst6*(y(1) - y(3))^2 + kst5*(y(1) - y(3))^3 + kst4*(y(1) - y(3))^4 + kst3*(y(1) - y(3))^5 + kst2*(y(1) - y(3))^6 + kst1*(y(1) - y(3))^7 - (M + m)*g)/m;
elseif tspan>=1 && y(3) - h > (M+m)*g/kt && (y(1) - y(3))<0 && (y(2) - y(4))>=0
f(4) = (csh7*(y(2) - y(4)) + csh6*(y(2) - y(4))^2 + csh5*(y(2) - y(4))^3 + csh4*(y(2) - y(4))^4 + csh3*(y(2) - y(4))^5 + csh2*(y(2) - y(4))^6 + csh1*(y(2) - y(4))^7 + cc*sign(y(2) - y(4)) + ksh7*(y(1) - y(3)) + ksh6*(y(1) - y(3))^2 + ksh5*(y(1) - y(3))^3 + ksh4*(y(1) - y(3))^4 + ksh3*(y(1) - y(3))^5 + ksh2*(y(1) - y(3))^6 + ksh1*(y(1) - y(3))^7 + ksh1*(y(1) - y(3))^7 - (M + m)*g)/m;
else
f(4) = (cst7*(y(2) - y(4)) + cst6*(y(2) - y(4))^2 + cst5*(y(2) - y(4))^3 + cst4*(y(2) - y(4))^4 + cst3*(y(2) - y(4))^5 + cst2*(y(2) - y(4))^6 + cst1*(y(2) - y(4))^7 + cc*sign(y(2) - y(4)) + ksh7*(y(1) - y(3)) + ksh6*(y(1) - y(3))^2 + ksh5*(y(1) - y(3))^3 + ksh4*(y(1) - y(3))^4 + ksh3*(y(1) - y(3))^5 + ksh2*(y(1) - y(3))^6 + ksh1*(y(1) - y(3))^7 + ksh1*(y(1) - y(3))^7 - (M + m)*g)/m;
end
end
In the code M stands for the sprung mass, m stands for the unsprung mass while kt is the tire stifness. Kst and Ksh are the coefficents of the two polynomials describing the behaviour of the suspension spring while it's stretching or shortening and the same is for Csh and Cst, where C is the damping coefficient. The goal of the code is to represent the behaviour of the model when it hits a step, so the road profile is described as 0 while tspan<1 and it's 0.01 m for tspan>1.
Now I want to ask you two questions: first of all I'd like to know if my code could be written in a more efficient way, because I realized that the introduction of simple nonlinearities makes the code slower. So I want to ask you if writing only two general equations describing f(2) and f(4) and evaluating all the parameters just one time at the beginning of every iteration could speed up the running of the script. In this case the code will be like
function f = solve(tspan,y)
load Data M m kt
load MollaNonLineare kst1 kst2 kst3 kst4 kst5 kst6 kst7 ksh1 ksh2 ksh3 ksh4 ksh5 ksh6 ksh7
load CoeffAmmo csh1 csh2 csh3 csh4 csh5 csh6 csh7 cst1 cst2 cst3 cst4 cst5 cst6 cst7
cc = 0;
g = 9.81;
if tspan<1
h = 0;
else
h = 0.01;
end
if y(1) - y(3)<0
k1 = ksh1;
k2 = ksh2;
else
k1 = kst1;
k2 = kst2
end
end
I didn't write the entire code purposely, because I don't want this question to become unnecessarily long, but the idea is that expressed in the previous lines.
My second question is about the introduction of a force related to the presence of friction in the components. I introduced the friction in a simple Coulombian way, using a coefficient cc and describing the force as
F = cc*sign(y(2) - y(4))
The problem which arises at this point is that the code becomes really slow, and I can't understand if this it's somehow related to the use of the sign function.Paolo Alloisiohttps://ch.mathworks.com/matlabcentral/profile/authors/14998737tag:ch.mathworks.com,2005:Question/5754552020-08-05T09:33:32Z2020-08-05T09:33:32Zsystematic random sampling from excel fileHello,
I have a list of people on an excel file. I need to select them with a systematic random sampling to ask them to participate in my experiment.
Can some expert of matlab tell the code to make matlab select them in a systematic random sampling.
Thank you!
Sincerely,
MigMigena Proihttps://ch.mathworks.com/matlabcentral/profile/authors/17732899tag:ch.mathworks.com,2005:Question/5754522020-08-05T09:31:26Z2020-08-05T09:31:26ZPlease help me how to proceed with the below equation to get A's and pi's values{AcosΦ}+i{AsinΦ}={Ae^iΦ}
i am having the values as follows
{0.167; 0.096}+i{0.3; -0.1}={Ae^iΦ}
Thanks in advance.
Venkata Rama Krishna Gonahttps://ch.mathworks.com/matlabcentral/profile/authors/17745533tag:ch.mathworks.com,2005:Question/5745432020-08-03T17:17:56Z2020-08-05T09:28:54ZAlgorithm to extract linearly dependent columns in a matrix Is there any general or standard approach to extract columns that are linearly dependent from the given matrix ?
Thanks and any help is apperciated !HNhttps://ch.mathworks.com/matlabcentral/profile/authors/6607164tag:ch.mathworks.com,2005:Question/5754492020-08-05T09:27:22Z2020-08-05T09:27:22ZControl the Parrot Mambo - Simulink Good Day all
I would like to change the PID controller in Parrot Mambo (Simulink) to SMController, is it possible?, if yes, shoul i change other simulink blocks or just the controller blocks?
Thanx in advanceyaya nethttps://ch.mathworks.com/matlabcentral/profile/authors/6052168tag:ch.mathworks.com,2005:Question/5754462020-08-05T09:25:57Z2020-08-05T09:25:57ZHow can I rotate many lines with different angles to be straight lines?How can I rotate many lines with different angles to be straight lines? The lines have been labeled.Na Nahttps://ch.mathworks.com/matlabcentral/profile/authors/19050373tag:ch.mathworks.com,2005:Question/5754432020-08-05T09:24:59Z2020-08-05T09:24:59ZFind equation of intersection of 3d curve (ellipsoid cylinder and plane)Hi and thanks ahead of time. I need to find two equations for the intersection of an ellipsoid cylinder and a plane:
I already have one equation of intersection that clearly works (everything after underlined section works), but I need to find a second and I'm lost. This is what I have so far.
The problem areas are underlined. I was thinking about trying to use solve to find an alternate way of representing the intersection, but I can't figure it out so far.
if true
% code
end
disp('Question #1');
%equation of intersection
[X,Y] = meshgrid(x,y);
t=linspace(0,pi);
x=t;
y=sqrt(1-(t^2)./4)+t-1;
z=sqrt(1-(t^2)./4);
surf(x,y,z)
n= input('Go on to question 1: second equation? Enter 0 for No or 1 for Yes');
if (n>0)
% code
clf, clear
end
disp('Question #1: second equation and illustration of intersection');
%equation of intersection
t=linspace(0, 2*pi);
T = meshgrid(t);
x=2*cos(T);
y=sin(T) + 2*cos(T) -1;
z=sin(T);
surf(x,y,z)
xlabel('x')
ylabel('y')
zlabel('z')
title('Mesh Plot')
grid on
hold on
%equation of ellipsoid cylinder
t=linspace(0, 2*pi);
T = meshgrid(t);
x=2*cos(T);
y=t;
z=sin(T);
surf(x,y,z)
hold on
%equation of plane
[x,y] = meshgrid (-5:1:5);
z=-1.*x+1.*y+1;
surf(x,y,z)Daniel Walkerhttps://ch.mathworks.com/matlabcentral/profile/authors/15596137tag:ch.mathworks.com,2005:Question/5703312020-07-25T02:50:01Z2020-08-05T09:24:36ZProblems in bounds in gamultiobj()with the folowing code:
opts = optimoptions('gamultiobj','PopulationSize',nvars, 'PopulationType', 'doubleVector','PlotFcn',{@gaplotpareto});
[f_GA, fval_GA] = gamultiobj(fun,nvars, [],[],[],[], lb, ub, opts);
f_GA does not respect ub and lb. I check all parameters carefully. All seems to be ok. But f_GA does not respect lu and ub. It has values outside of the lb and ub.
Please help. Sardar Haquehttps://ch.mathworks.com/matlabcentral/profile/authors/19071702tag:ch.mathworks.com,2005:Question/4690492019-06-26T18:49:18Z2020-08-05T09:22:59ZSimulink simulation won't start on Raspberry Pi3 in External Mode I am trying to run my Simulink model in external mode on a Raspberry Pi 3. I went through all of the setup and initial tests for the Simulink support package for Raspberry Pi. I checked to make sure my Raspberry Pi 3 is properly detected by going to Tools --> Run Target on Hardware --> Options, and then checking the "Target Hardware Resources" section. When I click run, the model builds properly and says "build process completed successfully". However, when the model begins to run on the Raspberry Pi 3, it stalls for a second at T = 0.000 s and then the simulation stops. The only message I get is in the matlab command window. See the warning messages below. Why isn't my simulation running on the Raspberry Pi?
Warning: Error returned by XCP master: XCP Master internal error: No slave connected
> In coder.internal.xcp.extmode_xcp_open
In coder.internal.xcp.extmode_xcp_open
In coder.internal.xcp.extmode_xcp_open
In ext_open_intrf>i_UserTargetStopped (line 992)
In ext_open_intrf (line 478)
Warning: XCP Master internal error: Busy(0) or no timeout(2) for 252
> In coder.internal.xcp.extmode_xcp_open
In coder.internal.xcp.extmode_xcp_open
In ext_open_intrf>i_UserTargetStopped (line 992)
In ext_open_intrf (line 478) Andrew Poissanthttps://ch.mathworks.com/matlabcentral/profile/authors/13072443tag:ch.mathworks.com,2005:Question/4957322019-12-09T15:25:35Z2020-08-05T09:17:47ZHow to display result in Text Area in Matlab AppdesignerHi, I have a problem here where I could not display my result of the equation in the text area.
Below is the code.
The app.EIRP.Value is the text area.
pt = app.ouputpower.Value;
lbo = app.backoffloss.Value;
lbf = app.eartbranchingloss.Value;
at = app.antennagain.Value;
lu = app.uplinkloss.Value;
lp = app.pathloss.Value;
gte = app.gteratio.Value;
bfb = app.satbranchingloss.Value;
br = app.bitrate.Value;
app.EIRP2 = pt+at-lbo-lbf;
app.EIRP.Value = num2str(eval(app.EIRP2));Noor Zaim Syafiq Nor Azamhttps://ch.mathworks.com/matlabcentral/profile/authors/14809357tag:ch.mathworks.com,2005:Question/5745012020-08-03T15:28:30Z2020-08-05T09:17:27ZMatrix compare and unkonw relationships to findI have 2 Matrix, for example
Matrix A ={a1 b1 c1; a2 b2 c2; a3 b3 c3}
Matrix B={x1 y1 z1 m1 n1; x2 y2 z2 m2 n2; x3 y3 z3 m3 n3 }
a1 b1 c1 is the result from FEM-Simulation-1, and x1 y1 z1 m1 n1 is the Geometrie-parameter from Simulation-Objekt-1
a2 b2 c2; x2 y2 z2 m2 n2 and the other number in Matrix means the same thing from Simulation-2 and -3.
there must some relationships zwischen Matrix A and B, linear or unlinear, but i don't yet.
How kann i use Matlab this unkonw relationships to find?
Or is it possible to use Matlab this unkonw relationships to find?
which function should i use?
Thankyou very very much for your time!Zuyu Anhttps://ch.mathworks.com/matlabcentral/profile/authors/16532151tag:ch.mathworks.com,2005:Question/5754342020-08-05T09:16:30Z2020-08-05T09:16:30Zgenerating pure tone and noiseHi, I want to generate 200 ms 950- 1050 Hz noise with rise/ fall time of 10 ms and a 1000 Hz , 25 ms pure tone with 10 ms rise/ fall time with 10 dB SNR and ISI of 20 ms
and fs= 44100
can any one help me pleaseParisahttps://ch.mathworks.com/matlabcentral/profile/authors/17678923tag:ch.mathworks.com,2005:Question/5742792020-08-03T07:00:29Z2020-08-05T09:15:18ZVector dimensions in my odeclc,clear all
k_s = 26400; %spring stiffness
m = 483; %Mass
f_n = sqrt(k_s/m)/(2*pi); %Natural frequency in Hz
%% Road profile
% spatial frequency (n0) cycles per meter
Omega0 = 0.1; %%%%conventional value of spatial frequency(n0)?
% psd ISO (used for formula 8)
Gd_0 = 32 * (10^-6);
% waveviness
w = 2;
% road length
L = 250;
%delta n
N = 1000;
Omega_L = 0.004;
Omega_U = 4;
delta_n = 1/L; % delta_n = (Omega_U - Omega_L)/(N-1);
% spatial frequency band
Omega = Omega_L:delta_n:Omega_U;
%PSD of road
Gd = Gd_0.*(Omega./Omega0).^(-w);
% calculate amplitude using formula(8) in the article
%Amp = sqrt(2*Gd*delta_n); %%%from Eq. 7?
%calculate amplitude using simplified formula(9) in the article
k = 3; %%%upper limit A and lower limit B k=3?
%Amp = sqrt(delta_n) * (2^k) * (10^-3) * (Omega0./Omega);
Amp = sqrt(delta_n) * (2^k) * (10^-3) * (Omega0./Omega);
%random phases
Psi = 2*pi*rand(size(Omega));
% x abicsa from 0 to L
x1 = 0:0.25:250;
h= zeros(size(x1));
%artificial random road profile
for iv=1:length(x1)
h(iv) = sum( Amp.*cos(2*pi*Omega*x1(iv) + Psi) );
end
%% ode45
T = 120;
x0 = [0,0];
f = @(t,x) [ x(2); -( k_s*(x(1)-h)/ m ) ];
[t, x] = ode45(f,[100,T],x0);
%% plot
plot(t,x(:,1));
set(gca,'xtick',17)
Hi, I generated a random road file (h) and tried to apply this in my ode, however it says the vector dimension is not consistent. Can anyone solve this problem please?Donghun Leehttps://ch.mathworks.com/matlabcentral/profile/authors/17824938tag:ch.mathworks.com,2005:Question/5736432020-08-01T03:51:37Z2020-08-05T09:14:34ZIf I use multi funcions with syms variable, How can I get track min value among that funcions?clear; clc; close all;
syms seta
Rx1= cos(seta)
Rx2= sin(seta)
If I set Rx1, Rx2 funcion like that, How can I get the graph with min value among Rx1, Rx2?
If I use discrete value, I can use like this
xmin=min([R1(x(:)');R2(x(:)');])
plot(x,xmin,'.-');
but, In this case I using Symbolic Math Toolbox, I don't know how I can make it works with syms variable...Gookki Jeonghttps://ch.mathworks.com/matlabcentral/profile/authors/8669692tag:ch.mathworks.com,2005:Question/5753952020-08-05T08:15:56Z2020-08-05T09:08:41Z<missing> displayed while i am printing the variable in command window I am writing a power allocation module for NOMA and i am trying to display my array of value After iterations more than 1200 my module starts to display NAN in arrays.
I tried to debug the probabale cause of it and found that one of my variable starts displaying <missing> in command prompt after certain iterations and when that value is added in my final array it becoms aalso NAN.
Can any body share why <missing> is displayed in command prompt (scrrenshot is attached here )Moin Alihttps://ch.mathworks.com/matlabcentral/profile/authors/19047623tag:ch.mathworks.com,2005:Question/5715762020-07-28T10:23:45Z2020-08-05T09:03:08ZFFT of time domain data from excelHi,
I am attaching my .csv file which is having time data (in microseconds)in first column & amplitude data in second column. Can anybody help me to plot a frequency spectrum of this data. Your help will be much appreciated as I am new to FFT in MATLAB.Yogesh Nadargehttps://ch.mathworks.com/matlabcentral/profile/authors/13276388tag:ch.mathworks.com,2005:Question/5754282020-08-05T09:03:07Z2020-08-05T09:03:07ZHow can I change the distances between points in a hexagonal grid?I'm trying to project some vectors in a hexagonal grid which is done with the hextop function.
Does anybody know how to change the distance between th points in the hexagonal grid?
vpos=[8,8];
pos=hextop(vpos);Clara Luque Riojahttps://ch.mathworks.com/matlabcentral/profile/authors/17546027