https://au.mathworks.com/matlabcentral/answers/questions.atomMATLAB Answers — New Questions2019-02-21T18:58:38Ztag:au.mathworks.com,2005:Question/4463092019-02-21T18:58:38Z2019-02-21T18:58:38Zcan i find correlation cofficient of uint8 onei have uint8 imageaaru srihttps://au.mathworks.com/matlabcentral/profile/authors/13164674-aaru-sritag:au.mathworks.com,2005:Question/4463082019-02-21T18:56:43Z2019-02-21T18:56:43ZLooking for an efficient way of finding elements in a cell array of character vectorsI have a cell array of character vectors, named "Channels", in which each entry corresponds a particular EEG channel label. I'd like to find indices that correspond to all P channels. For a single channel, P3, I have no problem. For example,
index = find(strcmp(Channels, 'P3'))
returns the correct index.
To find those indices that correspond to all four P labels, P3, P4, P7, P8, I can "glue" things together, such as
index = find(strcmp(Channels, 'P3')|strcmp(Channels,'P4')|strcmp(Channels,'P7')|strcmp(Channels,'P8'))
Of course, there has to be a more efficient way. I can't seem to find the correct manner to combine 'P3', 'P4', 'P7','P8' so so as to do it one step. Paul Fishbackhttps://au.mathworks.com/matlabcentral/profile/authors/3054555-paul-fishbacktag:au.mathworks.com,2005:Question/4462922019-02-21T17:35:29Z2019-02-21T18:53:45ZConverting cell array containing char to array.Hi,
I have a few cell arrays that contain char arrays that I need to convert to a single array. Currently the contents of the cell arrays are either numbers or [] for empty cells.
I tried cell2mat, str2num, str2double and all didn't work.
I attached one of the cell arrays.
Any help would be greatly appreciated.
ThanksMohamed Abdelsamiehttps://au.mathworks.com/matlabcentral/profile/authors/7241322-mohamed-abdelsamietag:au.mathworks.com,2005:Question/4462792019-02-21T16:40:00Z2019-02-21T18:53:08Zcopy and paste code with formattingIs there a way to copy from Matlab editor in a way that preserves formatting, so when I paste into another application it appears just as it did in Matlab? One possibility was if Matlab could receive a Notepad++ plug-in.
I realized that copy and paste works for the Matlab editor, but my actual application was to preserve formatting (font and color) in the Command Window.Larry Brunsonhttps://au.mathworks.com/matlabcentral/profile/authors/14844942-larry-brunsontag:au.mathworks.com,2005:Question/4463072019-02-21T18:51:42Z2019-02-21T18:51:42ZReading data row by row into matlab. I need to read a text file, row by row, into different variables. for the first 5 rows. After words an N x M matrix needs to be read in. Is there a simple way to do this? I've tried to use textrfead, fopen, etc, but can't figure out how to get just the numbers I need.
this would be a sample file:
8
10
12 15 12 18 17 19 14 16
200 155 487 632 526 321 845 80
52 41 78 62 32 45 67 85 29 10 15
followed by a matrix of size 8 x10 (the matrix will always be size of the first two inputs) Jorge Guzmanhttps://au.mathworks.com/matlabcentral/profile/authors/14653163-jorge-guzmantag:au.mathworks.com,2005:Question/4463062019-02-21T18:50:32Z2019-02-21T18:50:32ZDivide by Zero WarningHello,
I am trying to generate a warning when matlab divides by zero.
Running the following code:
warning on MATLAB:divideByZero
1/0
still does not generate an error.
I cannot find any official documentation about this feature being phased out, and it doesn't throw an error or anything when I try to turn the warning on. Does anybody have any suggestions as to how to get a warning when you divide by 0?
Thanks in Advance!
Kayla McCartyhttps://au.mathworks.com/matlabcentral/profile/authors/3612511-kayla-mccartytag:au.mathworks.com,2005:Question/4463032019-02-21T18:30:54Z2019-02-21T18:50:15ZHow to suppress the output of an mfile?When I run the code below the line in the for loop 'Unfortunately you didn''t win anything today, try again tomorrow!' isn't suppressed for some reason and is always displayed on the command window. Was wondering how to stop this.
%National Lottery number selector
Player_Numbers = [4 23 27 45 21 33];
numbers = [1:1:59];
Winning_Numbers = numbers(randperm(59,6))
similarity = intersect(Player_numbers,Winning_Numbers);
money = numel(similarity);
if money == 3
fprintf('Congratulations 3 of your numbers matched, you win £25!\n');
elseif money == 4
fprintf('Congratulations 4 of your numbers matched, you win £100!\n');
elseif money == 5
fprintf('Congratulations 5 of your numbers matched, you win £1000!\n');
elseif money == 6
fprintf('Congratulations all of your numbers matched! You win \n todays jackpot of £1,000,000!\n');
else
fprintf('Unfortunately you didn''t win anything today, try again tomorrow!\n');
endJoshua Papworthhttps://au.mathworks.com/matlabcentral/profile/authors/14663515-joshua-papworthtag:au.mathworks.com,2005:Question/4463042019-02-21T18:34:22Z2019-02-21T18:46:49Zhow can I transform this code into a for loopsubplot(3,3,1)
[S,f]=myFFT (x(0.1*fs:0.35*fs),fs);
plot(f,abs(S))
subplot(3,3,2)
[S,f]=myFFT (x(0.4*fs:0.65*fs),fs);
plot(f,abs(S))
subplot(3,3,3)
[S,f]=myFFT (x(0.7*fs:0.95*fs),fs);
plot(f,abs(S))
subplot(3,3,4)
[S,f]=myFFT (x(1.3*fs:1.55*fs),fs);
plot(f,abs(S))
subplot(3,3,5)
[S,f]=myFFT (x(1.6*fs:1.85*fs),fs);
plot(f,abs(S))
subplot(3,3,6)
[S,f]=myFFT (x(1.9*fs:2.15*fs),fs);
plot(f,abs(S))
subplot(3,3,7)
[S,f]=myFFT (x(2.2*fs:2.45*fs),fs);
plot(f,abs(S))
subplot(3,3,8)
[S,f]=myFFT (x(2.5*fs:2.75*fs),fs);
plot(f,abs(S))
subplot(3,3,9)
[S,f]=myFFT (x(2.8*fs:3.05*fs),fs);
plot(f,abs(S))Moussa Fofanahttps://au.mathworks.com/matlabcentral/profile/authors/13378270-moussa-fofanatag:au.mathworks.com,2005:Question/4461052019-02-20T19:41:55Z2019-02-21T18:45:33ZHow to find max and min of fuction of 2 independent variables?My question is how can I find minimum and maximum of this function, and then tag them with 'o' in function graph?
This is my code so far:
function funkcija(intervalpox,intervalpoy,korak,crtanje)
x=0:korak:intervalpox;
y=0:korak:intervalpoy;
[X,Y] = meshgrid(x,y);
Z = (sin(sqrt(X.^2 + Y.^2)) ./ (sqrt(X.^2 + Y.^2)));
mesh(X,Y,Z)
grid on
xlabel('.x.')
ylabel('.y.')
zlabel('.z.')
title('mesh')Faris Hajdarpasichttps://au.mathworks.com/matlabcentral/profile/authors/14824638-faris-hajdarpasictag:au.mathworks.com,2005:Question/4461442019-02-21T01:26:02Z2019-02-21T18:43:28Zhow to save filename from stringHi,
If I can same a string in a variable, is it possible to save a file name with this variable string, such that each time I run a loop, I can save the file name with a different name ?
The idea is shown below. Please ignore any syntax as I am trying to determine that
num = 'first'
rfwrite(first4portsparam, ' "the string num here ".s4p')
So in next loop I will replace
num = 'second'
rfwrite(first4portsparam, ' "the string num here ".s4p')
so in the end I will have 2 files first.s4p and second.s4p
Thanks !
Leojik Kannatharahttps://au.mathworks.com/matlabcentral/profile/authors/7777497-leojik-kannatharatag:au.mathworks.com,2005:Question/3666522017-11-13T02:10:43Z2019-02-21T18:43:00ZHow to get power system analysis toolbox(PSAT)?I want to do small signal stability analysis of a two area system with four generators. how do I get power system analysis toolbox(PSAT) for MATLAB?ARATHI VThttps://au.mathworks.com/matlabcentral/profile/authors/8639827-arathi-vttag:au.mathworks.com,2005:Question/4461592019-02-21T04:23:18Z2019-02-21T18:41:47ZWhile loop not terminating when condition is met?% This is a part of my code where all these variables that aren't defined here have
% been previously defined. W0g is a constant value and R is varied which changes W0
R = 1;
while 1
We_W0 = (a1+(b*W0g^C_1*AR^C_2*x_W0^C_3*W0_S^C_4*max^C_5))*Kvs
if(type == 1)
W3_W2 = exp((-R*SCF)/((V*(L_Dc))));
else
W3_W2 = exp(-(R*SCFpower)/((np*(L_Dc))));
end
Wf3 = W2_W1*W1_W0*W0g*(1-W3_W2);
Wf4 = W3_W2*W2_W1*W1_W0*W0g*(1-W4_W3);
Wf5 = W4_W3*W3_W2*W2_W1*W1_W0*W0g*(1-W5_W4);
Wftot = Wf1+Wf2+Wf3+Wf4+Wf5;
Wf = 1.06*Wftot;
W0 = (Wc+Wp+Wpd+Wf)/(1-We_W0);
if W0 == W0g
disp('Required range is');
disp(R);
break;
else R = R + 1;
end
end
The problem I'm having is that this condition is met. When I output the variable W0 there is a point where it is equal to W0g. Why is the while loop not stopping when this condition is met?
ThanksNick Nuzzohttps://au.mathworks.com/matlabcentral/profile/authors/11260177-nick-nuzzotag:au.mathworks.com,2005:Question/4463052019-02-21T18:37:58Z2019-02-21T18:37:58ZHow do i fix the error titled ''Unexpected exception (Package is not open) was caught''?Hello I am doing a simulation and i am trying in a script to run the simulink model and get result of an output for different parameter.
clc
clear all
close all
%Define parameter sets
iteration=275;
K_sweep=linspace(0.39,0.63375,275);
simout=cell(1,iteration);
%run the simulation command in a loop and collect the simualtion results
for idx=1:length(K_sweep)
%load Simulink model
load_system('MyMODEL');
set_param('MyMODEL/ESR','Resistance',num2str(K_sweep(idx)));
simout{idx}=sim('MyMODEL');
v122=V12(1:20920,1);
%Store values into
sad(:,idx)=v122;
end
but i get this error (though the simulation work and takes a few data and store them into the sad but then crashes)
the error is ''Unexpected exception (Package is not open) was caught''.
Can someone please tell me how can i fix this?
Marc Saadehttps://au.mathworks.com/matlabcentral/profile/authors/10846849-marc-saadetag:au.mathworks.com,2005:Question/4276982018-11-03T02:17:52Z2019-02-21T18:37:36ZExecute functions and read input simultaneously in MatlabI have an mp3 file which needs to go through different functions (blocks) in series. The input of each block is taken from the output of the previous block. Block C needs the longest time to process (eg. 10s). The problem is, instead of waiting the 10s, I wish to read another frame of mp3 while waiting the block C to finish its process. Any idea on the solution?
<</matlabcentral/answers/uploaded_files/139411/block.png>>
Starhttps://au.mathworks.com/matlabcentral/profile/authors/5883807-startag:au.mathworks.com,2005:Question/4460552019-02-20T15:13:04Z2019-02-21T18:35:49ZHow to find the coordinates of the white square ?Alaa Abusbeihhttps://au.mathworks.com/matlabcentral/profile/authors/14834940-alaa-abusbeihtag:au.mathworks.com,2005:Question/4461352019-02-20T23:41:36Z2019-02-21T18:32:29ZSigns in the output.h = [-1 -2 0]
j=sqrt(sum(h.^2));
%Number conversion into string format
k=num2str(h(1));
l=num2str(h(2));
m=num2str(h(3));
%Error message; distance input must be a positive real number
n=input('Enter the perpendicular distance from the origin: ');
if n<=0
disp('The distance cannot be zero or negative. Try again.')
else
o=['The equation of the plane at a perpendicular distance' ...
' of ', num2str(n),' from the origin O, is ', k,'x + ', ...
l,'y + ', m,'z = ', num2str(j*n),'.'];
disp(o)
end
When I input a distance of 2, the result is displayed as:
-1x + -2y + 0z = 4.4721.
Is there any way of displaying the output simply as:
-x - 2y = 4.4721.
where, the function automatically picks up the sign in the matrix and uses that instead of displaying both + and - . When the value is one it only displays the variable and when zero, it omits the variable from the output?
Thank you.
Mughees Asifhttps://au.mathworks.com/matlabcentral/profile/authors/14529788-mughees-asiftag:au.mathworks.com,2005:Question/4455992019-02-18T15:48:43Z2019-02-21T18:32:09ZValidation Accuracy on Neural networkHello..I wonder if any of you who have used deep learning on matlab can help me to troubleshoot my problem. I don't understand why I got a sudden drop of my validation accuracy at the end of the graph? It's a simple network with one convolution layer to classify cases with low or high risk of having breast cancer. After the final iteration it displays a validation accuracy of above 80% but then suddenly it dropped to 73% without an iteration. I don't understand that.
Here's my code
%set training dataset folder
digitDatasetPath = fullfile('C:\Users\UOS\Documents\Desiree Data\Run
2\dataBreast\training2');
%training set
imdsTrain = imageDatastore(digitDatasetPath, ...
'IncludeSubfolders',true,'LabelSource','foldernames');
%set validation dataset folder
validationPath = fullfile('C:\Users\UOS\Documents\Desiree Data\Run
2\dataBreast\validation2');
%testing set
imdsValidation = imageDatastore(validationPath, ...
'IncludeSubfolders',true,'LabelSource','foldernames');
%create a clipped ReLu layer
layer = clippedReluLayer(10,'Name','clip1');
% define network architecture
layers = [
imageInputLayer([256 256 1]);
% conv_1
convolution2dLayer(3,32,'Stride',1)
batchNormalizationLayer
clippedReluLayer(10);
maxPooling2dLayer(2,'Stride',2)
%fc
fullyConnectedLayer(100)
dropoutLayer(0.7,'Name','drop1');
%fc
fullyConnectedLayer(25)
dropoutLayer(0.8,'Name','drop2');
% fc layer
fullyConnectedLayer(2)
softmaxLayer
classificationLayer];
% specify training option
options = trainingOptions('adam', ...
'InitialLearnRate',0.001, ...
'MaxEpochs',15, ...
'Shuffle','every-epoch', ...
'ValidationData',imdsValidation, ...
'ValidationFrequency',30, ...
'Verbose',false, ...
'Plots','training-progress');
% train network using training data
net = trainNetwork(imdsTrain,layers,options);
% classify validation images and compute accuracy
YPred = classify(net,imdsValidation);
YValidation = imdsValidation.Labels;
%calculate accuracy
accuracy = sum(YPred == YValidation)/numel(YValidation);
Andrik Rampunhttps://au.mathworks.com/matlabcentral/profile/authors/14596665-andrik-rampuntag:au.mathworks.com,2005:Question/4462682019-02-21T15:23:07Z2019-02-21T18:27:46ZAdding a marker to Data Marker to Heatmap (via imagesc)Hello, i have a matrix Ib
2.29 2.29 2.29 2.29 1.89 1.89 1.89 1.89 1.77
2.29 2.29 2.29 2.29 1.89 1.89 1.89 1.89 1.77
1.77 1.77 1.77 1.77 1.89 1.89 1.89 1.89 0
1.77 1.77 1.77 1.77 1.89 1.89 1.89 1.89 0
2.81 2.81 2.81 2.81 1.89 1.89 1.89 1.89 0
2.81 2.81 2.81 2.81 1.89 1.89 1.89 1.89 0
0 0 0 0 2.50 2.50 2.50 2.50 0
I want to view as a heat map, so use imagesc to do this:
subplot(7,6,[22,23,24]);
imagesc(Ib2); colorbar; title('Std Background el','FontSize',8)
axis off
This gives me:
I want to be able to highlight any zeros visually and so wanted to either colour that data with a green colour, or if thats too difficuly just plot a green cross superimposed.
I have tried this:
[row,col]=find(Ib==0)
subplot(7,6,[22,23,24]); hold on;
plot(col,row,'gx')
But this just creates a new plot over the top.
Any suggestions please.
Thanks
Jason
Jasonhttps://au.mathworks.com/matlabcentral/profile/authors/1217570-jasontag:au.mathworks.com,2005:Question/4462992019-02-21T18:06:06Z2019-02-21T18:20:46Ztime string into secondsHello everyone! I have uploaded a column of time from excel in the format 'HH:MM:SS PM' as a string and I have converted it into Matlab as a datetime with datestr() . I don't know how to transfrom this column of time into seconds, because if I apply the formula : t*24*60*60 -t(1)*24*60*60 , I get the seconds but at a certain row of the vector I start having negative numbers. Could somebody help me? Thank youGeorge1990https://au.mathworks.com/matlabcentral/profile/authors/14303992-george1990tag:au.mathworks.com,2005:Question/4463002019-02-21T18:08:57Z2019-02-21T18:18:16ZHi. I am a complete novice at matlab and have been asked to create a 10x10 matrix in as few steps as possible. The first row has to be from 1:10, the second line from 2:11 and so on. How can I create this using repmat?%this is the matrix I want to achieve
A = zeros(10)
A(1,:)=[1:10]
A(2,:)=[2:11]
A(3,:)=[3:12]
A(4,:)=[4:13]
A(5,:)=[5:14]
A(6,:)=[6:15]
A(7,:)=[7:16]
A(8,:)=[8:17]
A(9,:)=[9:18]
A(10,:)=[10:19]
%How can I achieve this using repmat, reshape or meshgrid and the colon
%operator?
Sam Thorpehttps://au.mathworks.com/matlabcentral/profile/authors/14130396-sam-thorpetag:au.mathworks.com,2005:Question/4459152019-02-19T23:16:50Z2019-02-21T18:14:43ZLoop to pick random variables from separate probability distributionsI have a dataset that can be described by a beta probability distribution (alpha = 3.18, beta = 44.87). What I want to do is pick a random value from that beta probability distribution, and depending how many standard deviations away from the mean that value is, I would like to select a second random value from a lognormal distrbution (mu=45.89, sigma=151.595) that is also within the specific standard deviation range.
Summarized: if a value of 0.17 is picked from my beta distrbution (which lies to the right of the mean and is greater than 2nd std, but less than the 3rd std) then I want to pick a random value from my lognormal distrbution that is also to the right of the mean and greater than the 2nd std but less than the 3rd std).
Firstly, I apologize as I am very new to this (1 week in). But the main issue with my code is that I do not properly know how to pick a random value from my lognormal distrbution within a specific standard deviation range. In the below code I have this step simply as the placeholder: Perm = lognrnd(45.89,151.5956,[1 1]). I am also missing one line of code at the end of my for loop which would copy my porRandom value into one column and Perm into a second column after each of the 300 runs, resulting in a 300x2 matrix.
Thanks for taking the time!
number_of_runs = 300; % Run this loop 300 times
porRandom = betarnd(3.1800,44.87,[1 1]); % porRandom = random number generated from a beta distribution within a 1x1 matrix
Perm = (number_of_runs,1); % Generate a value for perm for each loop
for n = 1:number_of_runs;
if porRandom <= (mean(porDist) + std(porDist)) OR >= (mean(porDist) - std(porDist)); % if porRandom is within one standard deviation of the mean of a beta distrbution (porDist)
Perm = lognrnd(45.89,151.5956,[1 1]) % then let Perm be equal to a random value within one standard deviation of a defined lognormal distrbution
else if porRandom < (mean(porDist) - (std(porDist) AND > (mean(porDist) - ((std(porDist))*2)); % else if porRandom is within a 1st to 2nd standard deviation range (less than the mean)
Perm = lognrnd(45.89,151.5956,[1 1]) % then let Perm be equal to a random value within a 1st to 2nd standard deviation range (less than the mean) of a defined lognormal distrbution
else if porRandom < (mean(porDist) - (((std(porDist))*2)) % else if porRandom is greater than 2 standard deviations (less than the mean)
Perm = lognrnd(45.89,151.5956,[1 1] % then let Perm be equal to a random value that is greater than 2 standard deviations (less than the mean)
else if porRandom > (mean(porDist) + (std(porDist) AND < (mean(porDist) + ((std(porDist))*2)); % else if porRandom is within a 1st to 2nd standard deviation range (greater than the mean)
Perm = lognrnd(45.89,151.5956,[1 1] % then let Perm be equal to a random value within a 1st to 2nd standard deviation range (greater than the mean) of a defined lognormal distrbution
else porRandom > (mean(porDist) + (((std(porDist))*2)); % else porRandom is greater than two standard deviations (greater than the mean)
Perm = lognrnd(45.89,151.5956,[1 1] % then let Perm be equal to a random value that is greater than 2 standard deviations (greater than the mean)
end
Evan Renaudhttps://au.mathworks.com/matlabcentral/profile/authors/14770558-evan-renaudtag:au.mathworks.com,2005:Question/4463022019-02-15T05:00:00Z2019-02-21T18:14:25ZHow do I update a GUI designed in App Designer with data from a running Simulink model?I want to update a GUI that I have designed in App Designer using data that is generated during the simulation of a Simulink model. In other words, how do I access run-time parameters of a Simulink model from App Designer?
MathWorks Support Teamhttps://au.mathworks.com/matlabcentral/profile/authors/4622813-mathworks-support-teamtag:au.mathworks.com,2005:Question/4462402019-02-21T14:11:46Z2019-02-21T18:12:17Zchange stepsize of fminconHi
I am using fmincon to optimize the result of a unknown executable function (function.exe).
Fmincon changes the variables in the size of 1e-3 ~ 1e-4. But the result of the function leads to the same result. I'm sure that the changes are within the rounding tolerance of output of the function. How can i change the settings of fmincon to use a larger step size.
I already tried 'OptimalityTolerance', 'FiniteDifferenceStepSize' and 'DiffMinChange'. Non of them changed the stepsize of the variation of the variables.
GreetingsHeiko Scholzhttps://au.mathworks.com/matlabcentral/profile/authors/4363519-heiko-scholztag:au.mathworks.com,2005:Question/4463012019-02-21T18:11:43Z2019-02-21T18:11:43Zimporting data from .csv files of different lengths and same columns in matlab and getting RMS.I have a displacement data in 73 .csv files which are comma separated with 7 (fixed) columns and rows (varying) from 1500 to 9000 rows depending on the file. Each file contains 7 Columns as x y z(coordinates of voxels) and u v w(displacements in u v w directions) and sigma in 7th column. I want to create a code to read the .csv files and get the rms error in u v w directions respectively. RMS formula has to applied and i have to get 1 rms value for all the files combined and that too it should consider all the values of u v w in all the files.Can someone help me with the idea.I have attached the code which i used which i not working. I attached some files of the format .csv in the attachments.
data0001 = csvread('C://Users//User//Desktop//.csv//data_0001.csv');
.
.
.
.
.
data0071 = csvread('C://Users//User//Desktop//.csv//data_0071.csv');
data0072 = csvread('C://Users//User//Desktop//.csv//data_0072.csv');
data0073 = csvread('C://Users//User//Desktop//.csv//data_0073.csv');
%Root Mean Squared Error
for ii= 01:01:73
erroru{ii} = (sum((data00ii(:,4)).^2)); %error in u
errorv{ii} = (sum((data00ii(:,5)).^2)); %error in v
errorw{ii} = (sum((data00ii(:,6)).^2)); %error in w
U=erroru{ii}/(length(data00ii));
V=errorv{ii}/(length(data00ii));
W=errorw{ii}/(length(data00ii));
S= sum(U+V+W);
rmsError{ii} = sqrt(S);
show(rmsError{ii})
endkhaja inzimamhttps://au.mathworks.com/matlabcentral/profile/authors/11365287-khaja-inzimamtag:au.mathworks.com,2005:Question/4461322019-02-20T23:10:11Z2019-02-21T18:10:28ZSolve for symbol not finding explicit solutionHi all,
Im trying to isolate/solve an equition for a symbol, but both the solve and isolate function arent providing any solutions.
Heres my code:
clear
syms H SH AO RA;
t = sqrt(H / pi);
r = (0.506 * t + 1.0) / (1.79 * t^2 + 2.045*t + sqrt(2.0));
a = 1.0 / (0.803 * t^3 + 1.886 * t^2 + 2.524*t + 2.0);
c = 0.5 - r * sin(0.5 * pi * (a - t^2));
s = 0.5 - r * cos(0.5 * pi * (a - t^2));
eqn = ((pi * (cos(H / 2.0) * c + sin(H / 2.0) * s)^2) / ( RA^2 * (sin(H / 2.0 + AO))^2)) == SH;
answer = solve(eqn, H);
I've looked on this forum and google and ive tried a bunch of stuff but i cant figure this outJBertelinghttps://au.mathworks.com/matlabcentral/profile/authors/14838035-jbertelingtag:au.mathworks.com,2005:Question/4462952019-02-21T17:54:09Z2019-02-21T18:04:40ZMy loop runs indefinitely . How do I prevent thisv(1:13,1) = [3 4 5 6 7 8 9 10 11 12 13 14 15]
Ad = [-180.00 .000 .1748 .0000; -170.00 .230 .2116 .4000; -160.00 .460 .3172 .1018; -150.00 .494 .4784 .1333; -140.00 .510 .6743 .1727; -130.00 .486 .8799 .2132; -120.00 .415 1.0684 .2498; -110.00 .302 1.2148 .2779; -100.00 .159 1.2989 .2933; -90.00 .000 1.3080 .2936; -80.00 -.159 1.2989 .2933; -70.00 -.302 1.2148 .2779; -60.00 -.415 1.0684 .2498; -50.00 -.486 .8799 .2132; -40.00 -.510 .6743 .1727; -30.00 -.494 .4784 .1333; -20.10 -.560 .3027 .0612; -18.10 -.670 .3069 .0904; -16.10 -.790 .1928 .0293; -14.20 -.840 .0898 -.0090; -12.20 -.700 .0553 -.0045; -10.10 -.630 .0390 -.0044; -8.20 -.560 .0233 -.0051; -6.10 -.640 .0131 .0018; -4.10 -.420 .0134 -.0216; -2.10 -.210 .0119 -.0282; .10 .050 .0122 -.0346; 2.00 .300 .0116 -.0405; 4.10 .540 .0144 -.0455; 6.20 .790 .0146 -.0507; 8.10 .900 .0162 -.0404; 10.20 .930 .0274 -.0321; 11.30 .920 .0303 -.0281; 12.10 .950 .0369 -.0284; 13.20 .990 .0509 -.0322; 14.20 1.010 .0648 -.0361; 15.30 1.020 .0776 -.0363; 16.30 1.000 .0917 -.0393; 17.10 .940 .0994 -.0398; 18.10 .850 .2306 -.0983; 19.10 .700 .3142 -.1242; 20.10 .660 .3186 -.1155; 30.00 .705 .4784 -.2459; 40.00 .729 .6743 -.2813; 50.00 .694 .8799 -.3134; 60.00 .593 1.0684 -.3388; 70.00 .432 1.2148 -.3557; 80.00 .227 1.2989 -.3630; 90.00 .000 1.3080 -.3604; 100.00 -.159 1.2989 -.3600; 110.00 -.302 1.2148 -.3446; 120.00 -.415 1.0684 -.3166; 130.00 -.486 .8799 -.2800; 140.00 -.510 .6743 -.2394; 150.00 -.494 .4784 -.2001; 160.00 -.460 .3172 -.1685; 170.00 -.230 .2116 -.5000; 180.00 .000 .1748 .0000]
alpha = Ad(:,1)
alpharad = alpha*pi/180
cl = Ad(:,2)
cd = Ad(:,3)
r = [1.25800000000000 1.52200000000000 1.79800000000000 2.07500000000000 2.35200000000000 2.62800000000000 2.90500000000000 3.18100000000000 3.45800000000000 3.73500000000000 3.77200000000000 4.01100000000000 4.28800000000000 4.56500000000000 4.84100000000000 5.03000000000000]
twist = [20.0500000000000 14.0400000000000 9.67000000000000 6.75000000000000 3.84000000000000 3.48000000000000 2.40000000000000 1.51000000000000 0.760000000000000 0.0900000000000000 0.0000 -0.550000000000000 -1.11000000000000 -1.55000000000000 -1.84000000000000 -2]
c = [0.737000000000000 0.710000000000000 0.682000000000000 0.654000000000000 0.626000000000000 0.598000000000000 0.570000000000000 0.542000000000000 0.514000000000000 0.486000000000000 0.483000000000000 0.459000000000000 0.431000000000000 0.403000000000000 0.375000000000000 0.356000000000000]
twistrad = twist*pi/180
aprime = 0
summeP = 0
for k=1:13
V = v(k,1)
for i = 1:15
R = r(i,1)
C = c(i,1)
lamda = (7.536*R)/V
sigmap = C/(pi*R)
inn = sqrt(4-(4*pi*lamda*sigmap)+((pi*lamda*lamda*sigmap)*(40+(pi*sigmap))))
a = 0.25*(2+(pi*lamda*sigmap)-inn)
vn = (V*(1-a))
vt = (7.536*R)*(1+aprime)
twist1= twist(i,1)
phi = atan((vn)/(vt))
beta =( twist1+ 5)*(pi/180)
alpha1 = phi - beta
x = alpha1
cl1 = interp1(alpharad,cl,x)
cd1 = interp1(alpharad,cd, x)
% calculate root and tip loss factors
Ftipe =((5-R)/(R*sin(phi)))
Ftipe1 = (exp(-Ftipe))
Ftip = ((2/pi)*acos(Ftipe1))
Fhub = 1
F = (Ftip*Fhub)
ASAVED = a
a1 = (4*F*(sin(phi)*sin(phi)))
b2 = (sigmap*(cl1*cos(phi)+cd1*sin(phi)))
B = b2
a3 = 1/(1+(a1/B))
% determine aprime
APSAVED = aprime
Aprime1 = 1/(-1+((4*F*sin(phi)*cos(phi))/(sigmap*(cl1*sin(phi)-cd1*cos(phi)))))
% let us check to see if a and aprime converge enough
err = abs(ASAVED-a3)
err2= abs(APSAVED -Aprime1)
for j = 1:100
while (err2 > 0.005) && (err > 0.005)
a4 = a3(j, 1)
aprime2 = Aprime1
vn = (V*(1-a4))
vt = (7.536*R)*(1+aprime2)
twist1= twist(i,1)
phi = atan((vn)/(vt))
beta =( twist1+ 5)*(pi/180)
alpha1 = phi - beta
x = alpha1
cl1 = interp1(alpharad,cl,x)
cd1 = interp1(alpharad,cd, x)
Ftipe =((5-R)/(R*sin(phi)))
Ftipe1 = (exp(-Ftipe))
Ftip = ((2/pi)*acos(Ftipe1))
Fhub = 1
F = (Ftip*Fhub)
ASAVED = a4
a1 = (4*F*(sin(phi)*sin(phi)))
b2 = (sigmap*(cl1*cos(phi)+cd1*sin(phi)))
B = b2
a3 = 1/(1+(a1/B))
% determine aprime
APSAVED = Aprime2
Aprime2 = 1/(-1+((4*F*sin(phi)*cos(phi))/(sigmap*(cl1*sin(phi)-cd1*cos(phi)))))
% let us check to see if a and aprime converge enough
err = abs(ASAVED-a3)
err2= abs(APSAVED -Aprime2)
end
end
Liftprime = (0.6125)*((vn*vn)+(vt*vt))*cl1
Dragprime = (0.6125)*((vn*vn)+(vt*vt))*cd1
Propforceprime = (Liftprime*sin(phi)-(Dragprime*cos(phi)))
Bladeelepower = (1.884*Propforceprime*R)
Tbladeelepower = summeP + Bladeelepower(i)
end
Totalpowerv = 2* Tbladeelepower
end
Joshua Oladipohttps://au.mathworks.com/matlabcentral/profile/authors/14715220-joshua-oladipotag:au.mathworks.com,2005:Question/4462982019-02-21T18:00:01Z2019-02-21T18:00:01ZHow do I remove this error?%Clear Screen
clc;
%Clear Variables
clear all;
%Close figures
close all;
%Preallocate buffer
data_med = zeros(1,256);
%Comport Selection
portnum1 = 10;
%COM Port #
comPortName1 = sprintf('\\\\.\\COM%d', portnum1);
% Baud rate for use with TG_Connect() and TG_SetBaudrate().
TG_BAUD_115200 = 115200;
% Data format for use with TG_Connect() and TG_SetDataFormat().
TG_STREAM_PACKETS = 0;
% Data type that can be requested from TG_GetValue().
TG_DATA_MEDITATION = 3;
%load thinkgear dll
TGLib = 'C:\Users\Habibullah Khan\Desktop\matlabdll64\thinkgear64.dll';
loadlibrary(TGLib)
%To display in Command Window
fprintf('Thinkgear.dll loaded\n');
%get dll version
dllVersion =calllib('C:\Users\Habibullah Khan\Desktop\matlabdll64\thinkgear.h')%('Thinkgear', 'TG_GetDriverVersion');
%To display in command window
fprintf('ThinkGear DLL version: %d\n', dllVersion );
% Get a connection ID handle to ThinkGear
connectionId1 = calllib('Thinkgear', 'TG_GetNewConnectionId');
if ( connectionId1 < 0 )
error( sprintf( 'ERROR: TG_GetNewConnectionId() returned %d.\n', connectionId1 ) );
end;
% Attempt to connect the connection ID handle to serial port "COM3"
errCode = calllib('Thinkgear', 'TG_Connect', connectionId1,comPortName1,TG_BAUD_115200,TG_STREAM_PACKETS );
if ( errCode < 0 )
error( sprintf( 'ERROR: TG_Connect() returned %d.\n', errCode ) );
end
fprintf( 'Connected. Reading Packets...\n' );
i=0;
j=0;
%To display in Command Window
disp('Reading Brainwaves');
figure;
while i < 20
if (calllib('Thinkgear','TG_ReadPackets',connectionId1,1) == 1) %if a packet was read...
if (calllib('Thinkgear','TG_GetValueStatus',connectionId1,TG_DATA_MEDITATION ) ~= 0)
j = j + 1;
i = i + 1;
%Read attention Valus from thinkgear packets
data_med(j) = calllib('Thinkgear','TG_GetValue',connectionId1,TG_DATA_MEDITATION );
%To display in Command Window
disp(data_med(j));
%Plot Graph
plot(data_med);
title('Meditation');
%Delay to display graph
pause(1);
end
end
end
%To display in Command Window
disp('Loop Completed')
%Release the comm port
calllib('Thinkgear', 'TG_FreeConnection', connectionId1 );Habibullah khanhttps://au.mathworks.com/matlabcentral/profile/authors/14841089-habibullah-khantag:au.mathworks.com,2005:Question/4462972019-02-21T17:58:17Z2019-02-21T17:58:17Z Can someone please explain why I have an error?Abdulrahman Al Alihttps://au.mathworks.com/matlabcentral/profile/authors/13425589-abdulrahman-al-alitag:au.mathworks.com,2005:Question/4462962019-02-21T17:57:27Z2019-02-21T17:57:27Zswitch controlled by signal Like the picture showing, the simin block will has a series of data from matlab that only contains 0 and 1. I wanna the switch go to R1 when data is 0 and go to R2 when data is 1 during the simulation. How could I do this ? Thank you. ZHEN XUhttps://au.mathworks.com/matlabcentral/profile/authors/6389091-zhen-xutag:au.mathworks.com,2005:Question/4462932019-02-21T17:40:02Z2019-02-21T17:49:10Zhow to activate the matlab license After installing the MATLABsoftware , it should show LICENCE MANAGER ERROR -114,582.please give solution for this how to retrive these kind of problems.Kaviarasi Ezhumalaihttps://au.mathworks.com/matlabcentral/profile/authors/14625288-kaviarasi-ezhumalaitag:au.mathworks.com,2005:Question/4462912019-02-21T17:35:04Z2019-02-21T17:45:23ZHow to fix "index exceeds number of arrays error (1)" on my codeBelow is my function script:
function dcdt = func3a1(t,c)
global n aEG aCBH aBG Km1 Km2 Km3 Kg1 Kg2 Kg3 Kc1 Kc2 c0
%summations
A = 0;
for j = 3:n
A = A + c(j);
end
B = 0;
for k=3:n
B = B +(k-1)*c(k);
end
a = aEG./(B+Km1.*(1+c(1)./Kg1 + c(2)./Kc1));
b = aCBH./(A+Km2.*(1+c(1)./Kg2 + c(2)./Kc2));
r = aBG./(c(2)+Km3.*(1+c(1)./Kg3));
%differential equations of c1 and c2
dcdt(2)= 2*a*A + b*(A+c(4)) - r*c(2);
dcdt(1)= 2*a*A + b*c(3) + 2*r*c(2);
%differential equations for c(n=3:98)
for i = 3:n-2
dcdt(i,1) = a*2*(A-(i-1)*c(i))+b*(c(i+2)-c(i));
end
%differential equation for n=100 and n=99
dcdt(n) = a*(n-1)*c(n)-b*c(n);
dcdt(n-1) = a*(2*A-(n-2)*c(n-1));
end
And this is my ode solver script:
global n aEG aCBH aBG Km1 Km2 Km3 Kg1 Kg2 Kg3 Kc1 Kc2 c0
% Initial conditions and setup
n = 100;
c0 = 0.6; %mmol/L
aEG = 7; %mmol/L/h
aCBH = 12; %mmol/L/h
aBG = 6; %mmol/L/h
Km1 = 10; %mmol/L
Km2 = 1; %mmol/L
Km3 = 1; %mmol/L
Kg1 = 1; %mmol/L
Kg2 = 1; %mmol/L
Kg3 = 1; %mmol/L
Kc1 = 20; %mmol/L
Kc2 = 20; %mmol/L
x = (0:0.1:5); % the range of x
z = zeros(size(x)); % allocate the result y
y(1) = c0; % the initial y value
% The loop to solve the DE
[t,c] = ode15s(@func3a1,x,y);
%plots
figure(1)
plot(t,y(:,1),t,y(:,2));
xlabel('Time (h)');
ylabel('Concentrations');
legend('c1','c2');
I keep getting this error when I run my function and ode scripts:
Index exceeds the number of array elements (1).
Error in func3a1 (line 9)
A = A + c(j);
Error in odearguments (line 90)
f0 = feval(ode,t0,y0,args{:}); % ODE15I sets args{1} to yp0.
Error in ode15s (line 150)
odearguments(FcnHandlesUsed, solver_name, ode, tspan, y0, options, varargin);
Error in Ex1_3a (line 25)
[t,c] = ode15s(@func3a1,x,y);
Why does this keep appearing and how can I fix it?Natalia Gonzalezhttps://au.mathworks.com/matlabcentral/profile/authors/14713492-natalia-gonzaleztag:au.mathworks.com,2005:Question/4462872019-02-21T17:04:30Z2019-02-21T17:45:04ZI can't find where my mistake is?A=[1 2 -1; 2 2 -1; 2 5 2];
b=[3; 4; 2];
x=[1; 1; 1];
tol=1e-7;
d=diag(A);
X=ones(3,1);
r=ones(3,1);
while norm(r)/norm(X)>=tol
X=(b-A*x)./d+x;
r=X-x;
x=X;
end
X
%X should be 1 4/9 -10/9DShttps://au.mathworks.com/matlabcentral/profile/authors/14043820-dstag:au.mathworks.com,2005:Question/4461212019-02-20T21:06:26Z2019-02-21T17:44:09ZHow do I randomize a sequence of random numbers?Hi,
I've created a random sequence of numbers as shown below, but right now it just repeats the first 8 random numbers 13 times. How can I get it so that each sequence of 8 numbers is truly random from the next?
a = randi([1 4]);
b = randi([1 4]);
c = randi([1 4]);
d = randi([1 4]);
ASRTT = ([1 (a) 2 (b) 3 (c) 4 (d)]);
seqVectorX = repmat(ASRTT,1,13)';
Here's an example of the first two sequences for reference, where you can see the first 8 numbers are just starting over:
1 3 2 4 3 4 4 4 1 3 2 4 3 4 4 4
I added the line below but then it just scrambled all the numbers and didn't keep the ASRTT seqence of 1, random number, 2, random number, 3, random number, 4, random number.
seqVectorX= seqVectorX(randperm(numel(seqVectorX)));
Thanks in advance for any advice!Maria Yhttps://au.mathworks.com/matlabcentral/profile/authors/14479178-maria-ytag:au.mathworks.com,2005:Question/4462942019-02-21T17:41:35Z2019-02-21T17:41:35Zpseudo R2 calculation with mnrfit/mnrvalHi,
I'm doing a nominal logistic regression with mnrfit.
However, there is no in-built way of calculating different common pseudo-R² (pR2) for the regression.
I'd like to calculate some common pR2's for my regression and I know that dev = 2*ln(likelihood of my model).
E.g. McFadden's pR2 is 1- ln(full model)/ln(intercept model). Therefore, if I had the dev of the intercept model I could calculate McFaddens pR2
with 1-dev(full model)/dev(intercept model). But how do I calculate the intercept model?
Thanks,
RichardRichard Otthttps://au.mathworks.com/matlabcentral/profile/authors/12649233-richard-otttag:au.mathworks.com,2005:Question/4428492019-02-02T22:12:13Z2019-02-21T17:34:45ZHow do I subtract the following two images and determine the number of pixels in a certain section of an image?
How would I subtract the following two images of the same size? My goal is to subtract and remove the purple section so I can determine the number of pixels in the gray section on the lower left (below the black line). My problem is that the purple section in both images aren't exactly the same, since they are different frames of a video. Would it be easier to just focus on the second image using some image segmenting or edge detection technique? Please help me out.Jialu Wanghttps://au.mathworks.com/matlabcentral/profile/authors/12115027-jialu-wangtag:au.mathworks.com,2005:Question/4462902019-02-21T17:34:11Z2019-02-21T17:34:11ZConvert NNU License into SNU LicenseHello,
I have a NNU license on my machine. I want to ask if it is feasible to convert a NNU license into SNU license during a specific period of time. what is the followed procedure if it is OK ?
Thank you Mahmoud Moezhttps://au.mathworks.com/matlabcentral/profile/authors/11212857-mahmoud-moeztag:au.mathworks.com,2005:Question/4462572019-02-21T15:03:54Z2019-02-21T17:33:55ZHow can I do setdiff() between 2 arrays row by row without a loop?I'm trying to do the difference between 2 arrays with setdiff function but I don't get the expected result.
A = [15 8 5 9 10 14 17 7 20 12 6 16 2 4 11 13 3 1 19 18
10 19 13 15 1 16 6 14 17 8 11 18 20 5 2 12 7 9 4 3
15 8 5 9 10 14 17 7 20 12 6 16 2 4 11 13 3 1 19 18
13 12 3 14 4 19 2 16 10 18 20 6 15 5 7 17 1 9 11 8
13 12 3 14 4 19 2 16 10 18 20 6 15 5 7 17 1 9 11 8];
B = [16 19 15 5 8 1 3 20 14 18
4 14 13 2 20 9 15 7 6 12
14 2 12 13 4 8 5 19 18 20
3 10 19 13 15 1 16 6 14 17
12 11 6 10 13 7 16 19 15 5];
When I execute the instruction I get:
setdiff(A,B)
ans =
0×1 empty double column vector
But I would like to get:
out =[ 9 10 17 7 12 6 2 4 11 13
10 19 1 16 17 8 11 18 5 3
15 9 10 17 7 6 16 11 3 1
12 4 2 18 20 5 7 9 11 8
3 14 4 2 18 20 17 1 9 8];
Is there some way to get it without a loop?Izan Segarrahttps://au.mathworks.com/matlabcentral/profile/authors/6999599-izan-segarratag:au.mathworks.com,2005:Question/4458742019-02-19T18:10:46Z2019-02-21T17:29:04ZHow can I use simulink without time simulation?Hi everyone,
This is my very first time posting here. Let's say that I'm a "rookie" eager to learn more and more from Matlab and Simulink. I will be starting soon to start some simulink tasks at my job (with help from some guy who knows about Matlab) but I'm developing (or trying) to do some things on my own just to progress.
I want to build a simulink model which has to read the data from an Excel file. The data in the Excel comes from a data acquisition system which has logged:
1 column for air pressure
1 column with time (1 read every 1 milisecond -1kHz-)
The purpose of my model is to read the air pressure value and integrate it but it has to do it according to the corresponding recording time in the cell of the adjacent column. I'm stuck at understanding how simulink performs the simulations because I want the model to introduce the air pressure value read every 1 milisecond as recorded in the data acquisition system but I'm forced to set a simulation time in simulink which doesn't match my data.
How can I tell Simulink "hey, this is my air pressure at 1 milisecond, integrate it, then, this is my air pressure at 2 miliseconds and integrate it" and so on?
I hope my question is clearDavid Rojas Blancohttps://au.mathworks.com/matlabcentral/profile/authors/13835317-david-rojas-blancotag:au.mathworks.com,2005:Question/4462712019-02-21T15:53:50Z2019-02-21T17:28:16Zfsk with flat fadingHello evry one
I have this 10 bit fsk signal and i want to add flat fading to it please any one can help me , or to rewrite anew code of fsk signal that easy to add flat fading
n=randi([0 1],1,10);
j=1;
t=0:.005:length (n);
for L=1:length(t);
if t(L)<=j
y(L)=n(j);
else
y(L)=n(j);
j=j+1;
end
end
f1=3;
f2=5;
y1=sin(2*pi*f1*t);
y2=sin(2*pi*f2*t);
for j=1:length(t)
if y(j)==1
z1(j)=y1(j);
else
z1(j)=y2(j);
end
end
to it?ali alabodihttps://au.mathworks.com/matlabcentral/profile/authors/14408556-ali-alaboditag:au.mathworks.com,2005:Question/2861072016-05-27T17:15:55Z2019-02-21T17:27:36ZHow to get b vs V plot for multimode optical fiber using matlab with using bessel's equation? I want to plot b vs. V curve for different modes of optical waveguide(https://www.google.co.in/url?sa=i&rct=j&q=&esrc=s&source=images&cd=&cad=rja&uact=8&ved=0ahUKEwjB-tTg3_rMAhVCGaYKHfpeBb4QjRwIBw&url=http%3A%2F%2Fwww.slideshare.net%2Ftossus%2Fwaveguiding-in-optical-fibers&psig=AFQjCNFhFM8YX_nSP2G-HHetH4b5GEB79A&ust=1464455430166614). There i need to solve bessel's equation with the help of numerical methods, specially by Newton Raphson Method. Can anyone please tell me the matlab code which uses Newton Raphson method for solving bessel's equation?Subhajit Karmakarhttps://au.mathworks.com/matlabcentral/profile/authors/6122148-subhajit-karmakartag:au.mathworks.com,2005:Question/4459952019-02-20T10:55:52Z2019-02-21T17:27:27ZHow do i plot ECG sensor data from arduino to ECG graph using matlab?Can anyone share with the code on how to plot ECG sensor data into ECG graph using Matlab visualization in Thingspeak. I am able to do using Processing IDE.I want to do the same in Thingspeak.
Teh processing code is https://github.com/sparkfun/AD8232_Heart_Rate_Monitor. I want the equivalent matlab code. I am not able to get the equivalent.
Please someone help me.Sai Pavan Nunnahttps://au.mathworks.com/matlabcentral/profile/authors/7120588-sai-pavan-nunnatag:au.mathworks.com,2005:Question/3460582017-06-23T20:29:45Z2019-02-21T17:27:21ZHow to write a mixed data (text and number) in a CSV file ?I need to write a CSV file with text matrix in the first column and numbers matrix in the second column.
Example
matrix1 = {'water';'space';'fire'};
matrix2 = [100;200;300];
CSV file output as:
water,100
space,200
fire,300
Please provide me some direction to solve this problem. Please let me know for further information.
Thanks in advance,
RamRaguram Nhttps://au.mathworks.com/matlabcentral/profile/authors/9542561-raguram-ntag:au.mathworks.com,2005:Question/4462882019-02-21T17:27:20Z2019-02-21T17:27:20Zsaving gray scale images in a 3D arrayI want to save 4 gray scale images in a 3D array and use them. I wrote the following code for this purpose but it did not work!
object_dataset1(:,:,1)=rgb2gray(imread('object1_1.jpg'));
object_dataset1(:,:,2)=rgb2gray(imread('object1_2.jpg'));
object_dataset1(:,:,3)=rgb2gray(imread('object1_3.jpg'));
object_dataset1(:,:,4)=rgb2gray(imread('object1_4.jpg'));
when I use the imshow function to show one of the images it show a white surface!!
for example : imshow(object_dataset1(:,:,2));Salarhttps://au.mathworks.com/matlabcentral/profile/authors/14316070-salartag:au.mathworks.com,2005:Question/4459872019-02-20T10:07:20Z2019-02-21T17:24:04Z"Subscripted assignment dimension mismatch" error Hello, i'm stuck at an issue in line 33 (Converting the UTC dates in the timetable to Local solar time (LST)) where it gives me this error "Subscripted assignment dimension mismatch" and i have no idea how to fix it. I have added another file next to the code which includes the timetable used in some of the equations. Any help will be greatly appreciated. Thanks.
mohamed heshamhttps://au.mathworks.com/matlabcentral/profile/authors/14627214-mohamed-heshamtag:au.mathworks.com,2005:Question/710782013-04-08T19:12:03Z2019-02-21T17:22:40ZCommand Window Output to GUIHello everyone,
I'm creating a GUI and at some point of it I need to run some cshells that begin printing many notifications in the command window. This all works fine, however, it would be great if all that output can be printed in the GUI itself. Is there a way of doing this? Sort of like cloning the command window into a "Static Text" field or similar in the GUI.
Any help is appreciated.carlos Uribehttps://au.mathworks.com/matlabcentral/profile/authors/2677021-carlos-uribetag:au.mathworks.com,2005:Question/4453422019-02-16T21:13:43Z2019-02-21T17:20:58ZHow to properly run simple Simulink circuit?Good day,
I am having issues with simulink. I am trying to simulate a portion of a circuit that I am trying to develop. I am just not understanding how simulink works. I created a portion of my circuit, stepping up a 12V DC voltage from a battery (from a DC to DC converter) to 4.5kv and it's suppose to charge a capacitor.
Source is 12 V - stepping it up to 4.5kV, and the capacitor should be charged at 4.5kV of course. I put a volt meter or a "voltage sensor" in parallel with the capacitor to verify the voltage.
The potentionmeter is used to adjust the DC-to-DC converter output (output should be somewhat linear to input). In real life, I have a dc-to-dc converter that has a max output of 6000V, and 1.67mA. At max, it draws a maximum of 1.5A. The dc-to-dc converter that I have is a 12V source.
I have attached the file, I hope someone can help me. This is driving me nuts.
When I am trying to run it, I am getting the following error.
I am using simscape for this. If there is a better recommendation please let me know.
Thank you in advance!!!
The model may not give enough information to make it possible to solve for values of some of its variables. Specific advice is given below.
Tie variable 'Voltage_Sensor.p.v' (Voltage) to a definite value, for example by connecting an appropriate domain reference block.
Dependency found among topology equations. Check for missing reference node.
Component:Simulink | Category:Modelwarning
The model may not give enough information to make it possible to solve for values of some of its variables. Specific advice is given below.
Tie variable 'Voltage_Sensor.p.v' (Voltage) to a definite value, for example by connecting an appropriate domain reference block.
Dependency found among topology equations. Check for missing reference node.
Component:Simulink | Category:Modelwarning
An error occurred while running the simulation and the simulation was terminated
Caused by:
At time 0.000000, an assertion is triggered. Supply-side current exceeded the Maximum expected supply-side current. The assertion comes from:
Block path: step_up_charge_cap/DC-DC Converter
Assert location: (location information is protected)
Component:Simulink | Category:Blockerrorcancel077https://au.mathworks.com/matlabcentral/profile/authors/2013163-cancel077tag:au.mathworks.com,2005:Question/4462362019-02-21T13:58:47Z2019-02-21T17:17:41ZSNR between two images in MATLABBelow is the algorithm for calculating the SNR of two images in MATLAB:
A = imread('Yes_Noise.png');
A = imgaussfilt(A, 2); %Filtered image
ref = imread('Yes_Noise.png'); %Noisy image
test = snr(ref,ref-A)
Is it the algorithm rigth? It's purpose is find out the SNR value between filtered and nosiy image.
Franta Cymorekhttps://au.mathworks.com/matlabcentral/profile/authors/9262056-franta-cymorektag:au.mathworks.com,2005:Question/3090042016-10-25T04:12:01Z2019-02-21T17:17:22Zhow do I find the extreme points?y = x(sin(x))^2 with a domain interval of [-0.5, 0.5]
Have been trying to work this problem out and can't seem to figure it out..Chad Lovehttps://au.mathworks.com/matlabcentral/profile/authors/8692303-chad-lovetag:au.mathworks.com,2005:Question/4462702019-02-21T15:46:21Z2019-02-21T17:12:04Zfor and while loops in matlabBackground:
This program will focus on providing arithmetic practice for users who want to test their knowledge of basic multiplication (and potentially addition, subtraction, and division). There are minimum requirements for the program. Once you have met the minimum requirements, you have the option of adding more features that can increase your score well beyond 100% on this assignment. These additional points can offset points lost on previous in-class programming assignments.
Design Statement:
Write a fully commented MATLAB script that will allow the user to practice basic multiplication ("2s" through "12s") by ...
Minimum Requirements: (20 points total)
(1 pt) Prompting the user to select an integer value between 2 and 12, inclusive
(8 pts) Randomly generating successive, unique (e.g. non-repeating) multiplication problems that involve multiplying the integer selected in the previous step by an integer value between 2 and 12, inclusive. ("Game Mode 1")
(3 pts) As soon as the user enters an incorrect answer, the script should stop generating problems and output the following information:
You correctly answered __ multiplication problems in a row involving __s.
where the number of correctly answered problems appears in the first blank and the integer the user selected in the first step appears in the second blank.
Note: You must include full header comments that cover the minimum requirements. You do not have to update the header comments for additional features that you add. (5 points for header comments, 3 points for logic comments)
Optional additional features: You can now build on the based code to add functionality. For each additional feature, you can earn additional points. The maximum point value for each feature is specified in parentheses, though I reserve the right to give more points if I am particularly impressed.
Note: Each additional feature should include clear comments within the code that make it clear what additional functionality is being added. If it is not clear from these comments AND any associated prompts what feature is being added, then points will not be awarded. You do NOT have to add information to the header comments for the additional features ... since you have limited time.
(10 pts) Add another "Game Mode" for the user to choose from that randomly generates 10 unique (e.g. non-repeating) problems and then reports the results with the following text string:
You correctly answered __ out of __ problems (__%) involving __s.
where the number of correctly answered problems appears in the first blank, the total number of problems appears in the second blank, the percentages of problems answered correctly appears in the third blank, and the integer the user selected in step 1a appears in the last blank.
Include additional practice modes that can be selected by the user.
(10 pts) Addition
(10 pts) Subtraction
(15 pts) Division ... where the user provides quotient and remainder values for each problem
(5 pts) Add graphical reporting for each Game Mode.
Allow the user to modify ...
(5 pts) Game Mode 1 by choosing how many incorrect answers are allowed before the program stops generating problems and reports the output
(5 pts) Game Mode 2 by choosing how many successive problems to generate before the program reports the output
(5 pts) After the user completes one "round," provide them with the option to start a new round without having to run the program again.
(?? pts) Propose an original feature and then implement it.
Verify that the script works correctly.abdul dhwhhttps://au.mathworks.com/matlabcentral/profile/authors/14826374-abdul-dhwhtag:au.mathworks.com,2005:Question/4452522019-02-16T02:55:05Z2019-02-21T17:11:50ZCreating plot with 2 x axesI have written the following snippet of code for creating a plot with two x axes
figure(),
x1 = linspace(0,100,101);
y1 = sin(x1);
plot(x1,y1)
xlabel('Loss (%)')
ylabel('Energy Efficiency (%)')
x2 = x1*5*40000/100;
ax1 = gca;
ax1_pos = ax1.Position;
ax2 = axes('Position', ax1_pos, 'XAxisLocation', 'top', 'YAxisLocation', 'right');
plot(x2, y1, 'Parent', ax2);
I have configured the 2nd x axis to be on the top, but I get the following, where the two x axes overlap:
I tried the code in this post: https://www.mathworks.com/help/matlab/creating_plots/graph-with-multiple-x-axes-and-y-axes.html?searchHighlight=two%20x-axes
and the code works. But I don't understand what's the problem with my code. Could anybody explain please?Md. Rahmanhttps://au.mathworks.com/matlabcentral/profile/authors/4044690-md-rahman