https://nl.mathworks.com/matlabcentral/answers/questionsMATLAB Answers — New Questions2020-01-18T23:44:15Ztag:nl.mathworks.com,2005:Question/5009122020-01-18T22:50:22Z2020-01-18T23:44:15ZChange value for another valueI have some 99999 values in my array.
I want to change all of them to 0.
Is there code to change all the values at once?
Or do I need to change values in every column of the array?
Sarah Yunhttps://nl.mathworks.com/matlabcentral/profile/authors/16837202-sarah-yuntag:nl.mathworks.com,2005:Question/5008152020-01-17T22:42:56Z2020-01-18T23:41:08ZCreate an .m fileCreate an .m file that is a function that creates an array of N random integers in the range from -9999 to 9999. It should be in the form of x=randint(N).
NOTE: This time, upload as an m file, not as a published Word document. You'll be using these functions in a later quiz. But you should test that it works on your own because I will be verifying it in MATLAB when I grade.
Create an .m file that is a function that finds the maximum value in an array of numbers. It should be in the form of max=maxval(x). Do not use built in function max.
NOTE: This time, upload as an m file, not as a published Word document. You'll be using these functions in a later quiz. But you should test that it works on your own because I will be verifying it in MATLAB when I grade.
I have watched the video for this class multiple times and have zero ideas of how to tackle this. These are the first couple of question for the section and I think that if i got helpe on these ones, I could do the rest.Benjamin Trivershttps://nl.mathworks.com/matlabcentral/profile/authors/17203739-benjamin-triverstag:nl.mathworks.com,2005:Question/5009152020-01-18T23:33:58Z2020-01-18T23:36:46ZIs it possible to split the Command Window into continuous sub Command Windows?Suppose I set the command window (CW) to take as much space as possible on the IDE (not necessary, just to make a better point).
If I want to see lots of output at the same time, the CW is too short, but also too wide. Is there a way to split the CW into two (or more) windows, side by side, so that they concatenate and text flows from the top of one to the bottom of the next (CW shows newer output at the bottom)?
I have seen you can't have more than one CW in the same Matlab instance, but in this case it would not be multiple independent CW but the same, just cut and stacked to the side.
Thanks in advance.Alejandro Guzmán Martín-Ondarzahttps://nl.mathworks.com/matlabcentral/profile/authors/7297906-alejandro-guzman-martin-ondarzatag:nl.mathworks.com,2005:Question/4799692019-09-11T18:45:15Z2020-01-18T23:36:38ZWhy doesn’t livescript display the results in LATEX form?When I was using 2017a the results of symbolic operations resulted in LATEX form but why does it not happening in 2018b? Is there any option to change the settings perhaps? madhan ravihttps://nl.mathworks.com/matlabcentral/profile/authors/12308260-madhan-ravitag:nl.mathworks.com,2005:Question/4804142019-09-14T22:34:42Z2020-01-18T23:33:43ZThingspeak - Expired License message & upload stopped workingAfter login I got sweet message:
Expired License
Your trial license has expired as of September 4, 2019.
In account settings:
License Type: Free
Expiration Date: 04 Dec 2019
Available Remaining
Messages 3 000 000 2 851 627
Channels 4 2
Upload to channels stopped working on september 4th...Mic Sohttps://nl.mathworks.com/matlabcentral/profile/authors/16166494-mic-sotag:nl.mathworks.com,2005:Question/5009142020-01-18T23:26:10Z2020-01-18T23:26:10ZHow to avoid getting negative values when training a neural network?Is there anyway to constrain the network results when we train a feed forward neural network in Matlab?
I am trying to train a supervised feed forward neural network with 100,000 observations. I have 5 continues variables and 3 countinues responses (labels). All my values are positive (labels and variables). However, when I train the network, sometimes it predicts negative results no matter what architecture I use. Negative results does not have any physical meaning and should not apear. Is there anyway to constrain the network? I also used reLU activation function for the last layer but the network cannot generalize well.
Thanks
Mostafa Nakhaeihttps://nl.mathworks.com/matlabcentral/profile/authors/15200686-mostafa-nakhaeitag:nl.mathworks.com,2005:Question/5009102020-01-18T22:24:59Z2020-01-18T23:14:31ZHow to assign numbers to letters of the alphabet. Ex. A/a=1 B/b=2As the title stated. I need to write a function where the input of a certain letter will give me the output of its corresponding number. (based off ASCII table)
Ex. someFunction (A)
ans = 1
someFunction (f)
ans = 6
Thanks for the help in advanced!Orion Sunhttps://nl.mathworks.com/matlabcentral/profile/authors/17204215-orion-suntag:nl.mathworks.com,2005:Question/2230062015-06-08T17:00:57Z2020-01-18T23:13:37ZSimulink Library Browser doesn´t show any blocksHello everybody,
I just installed Matlab 2015a (academic license) and found the simulink library browser empty, besides the recently used blocks entry (which is empty).
System is a Win7 Proffesional 64bit.
What can I do about it?Stephan Hehttps://nl.mathworks.com/matlabcentral/profile/authors/4566813-stephan-hetag:nl.mathworks.com,2005:Question/5009132020-01-18T22:52:43Z2020-01-18T22:52:43ZI want to help draw the wave for synchronous generator inductive load% Simulation of a loaded synchronous generator.
%%
clc
clearvars
close all
%% Parameters
V_oc = 480; % open circuit voltage
f = 50; % frequency (Hz)
Xs = 1; % generator's reactance
Ia = 60; % load current
PF = 0.8; % power factor
%% Calculations
Ea = V_oc / sqrt(3); % armature voltage magnitude
theta = acosd(PF);
V_phi = sqrt(Ea^2 - (Ia*Xs*PF)^2) - Xs*Ia*sind(theta);
Ia_phsr = Ia * exp(-1i*theta*pi/180); % load phasor current
% Ia_phsr = Ia * ( cosd(theta)-1i*sins(theta)); % load phasor current
V_arm_drop = 1i*Xs*Ia_phsr;
Ea_phsr = V_phi + V_arm_drop;
%% Plotting
close all
axis square
plot([0 real(V_phi)], [0 imag(V_phi)]) % V_phi
hold on
plot([0 real(Ia_phsr)], [0 imag(Ia_phsr)],'k') % Ia phasor
plot([0 real(Ea_phsr)], [0 imag(Ea_phsr)],'r') % Arm voltage
legend('V_{\phi}','I_A','E_A','location', 'northwest')
sara gamalhttps://nl.mathworks.com/matlabcentral/profile/authors/11160878-sara-gamaltag:nl.mathworks.com,2005:Question/4996702020-01-09T21:48:07Z2020-01-18T22:49:41Zincorrect memory copy when using property size validatorWhen using a size validator in a property block of a class an assigned variable's memory is copied instead of just pointing to it. This is 1) not expected due to standard matlab behavior, and 2) does not happen if using a manual set.prop(this, in) method to do the validation check.
There is then a secondary bug that when assigning a gpu variable and memory runs out (due to this memory bug) instead of giving an out of memory error, I instead get a size validation check did not pass error.
I see the same error on 2019b on a different computer. Example code below:
classdef TestClass < handle
properties
prop (1, :) % also happens with hard coded sizes and n-dimensional arrays
end
end
g = gpuDevice; g.AvailableMemory
ans =
5.2493e+09
>> a = ones(1, 3e8, 'single', 'gpuArray');
g = gpuDevice; g.AvailableMemory
ans =
4.0493e+09 % 1.2GB hit as expected
>> obj = TestClass;
>> obj.prop = a;
>> g = gpuDevice; g.AvailableMemory
ans =
2.8493e+09 % another 1.2GB hit, not expectedKylehttps://nl.mathworks.com/matlabcentral/profile/authors/887991-kyletag:nl.mathworks.com,2005:Question/5009112020-01-18T22:35:55Z2020-01-18T22:44:35ZVERY slow for loopI have a very slow for loop in my script, it meant to sort a column in a text file (about 500,000 rows) and remove lines with negative values. it took ~10600 sec to finish this lines. Is this normal? any way to improve it?
this is the code:
for i = 1:height (T1(:,2)) %remove negative numbers from column 2
if lt(T1.energy,0)
continue;
else
T1(T1.energy < 0, :) = [];
end
end
thanks!sanihttps://nl.mathworks.com/matlabcentral/profile/authors/6350539-sanitag:nl.mathworks.com,2005:Question/5008912020-01-18T17:18:33Z2020-01-18T22:36:30ZVectors must be the same length - No idea why they are not!Hi everyone!
I am attaching a code that eventually will evaluate the performance of a numerical model against observational values. Up to this point, I am inserting .xlsx files that contain measurements from several weather stations.
The error appears in line 182, when I try to plot mean hourly values of temperature. Y axis should be Hourly_Temp_mean and X axis H_date_Unique. In my mind these two must have equal dimensions but it appears that this is not the case. Of course with different dimensons, the plot cannot be produced.
Any contributions will be much appreciated....Daphne PARLIARIhttps://nl.mathworks.com/matlabcentral/profile/authors/17231339-daphne-parliaritag:nl.mathworks.com,2005:Question/5008132020-01-17T22:16:23Z2020-01-18T22:32:38ZWhy does Matlab keep forgetting my path?It seems that since around 3 ro 4 years ago, my current installation of matlab seems to regularly forget the directories I have manually added to the path. Several times i have called tech support and they do some chache clearing, path rebuilding and whatnot, and it is fixed. Then a few months later is is broke again. I can keep fixing it, but wondering why. I never had issues in the 20 years prior!Todd Weltihttps://nl.mathworks.com/matlabcentral/profile/authors/57524-todd-weltitag:nl.mathworks.com,2005:Question/5008952020-01-18T17:46:55Z2020-01-18T22:31:10ZDot indexing is not supported for variables of this type ErrorHello,
I am trying to run this loop in a function
for i = 1:1:size(GlobalMeshonBody_1,1)
nE =size(GlobalMeshonBody_1(i).IndivualStiffnessMatrix,2);
end
and I am getting this error:
"Dot indexing is not supported for variables of this type."
But if I run the above loop in the main script, I get no errors at all...
The answer is get is
nE = 7;
Does anyone know?hamzah khanhttps://nl.mathworks.com/matlabcentral/profile/authors/7944651-hamzah-khantag:nl.mathworks.com,2005:Question/5008322020-01-18T03:53:34Z2020-01-18T22:22:51ZHow can I turn the following code to a surface plot function Visualize2(X, Y, E, F, k)
if k==4
k1=2; k2=2;
elseif k==2
k1=1; k2=2;
end
figure;
X=X'; Y=Y'; E=E'; F=F';
%Show the original manifolds
subplot(k1,k2,1);
plot3(X(:,1), X(:,2), X(:,3),'r-', 'LineWidth',.5);
hold on;
plot3(Y(:,1), Y(:,2), Y(:,3),'b-', 'LineWidth',.5);
title({['(A) Before Alignment']});
xlabel('X', 'FontSize',12, 'FontWeight', 'bold');
ylabel('Y', 'FontSize',12, 'FontWeight', 'bold');
zlabel('Z', 'FontSize',12, 'FontWeight', 'bold');
% 3D
subplot(k1,k2,4);
plot3(E(:,1), E(:,2), E(:,3),'r-', 'LineWidth',.5);
hold on;
plot3(F(:,1), F(:,2), F(:,3),'b-', 'LineWidth',.5);
title({['(B) After 3D Alignment']});
xlabel('X', 'FontSize',12, 'FontWeight', 'bold');
ylabel('Y', 'FontSize',12, 'FontWeight', 'bold');
zlabel('Z', 'FontSize',12, 'FontWeight', 'bold');
if k==4
% 2D
subplot(k1,k2,3);
plot(E(:,1), E(:,2), 'r-', 'LineWidth',.5);
hold on;
plot(F(:,1), F(:,2), 'b-', 'LineWidth',.5);
title({['(C) After 2D Alignment']});
xlabel('X', 'FontSize',12, 'FontWeight', 'bold');
ylabel('Y', 'FontSize',12, 'FontWeight', 'bold');
zlabel('Z', 'FontSize',12, 'FontWeight', 'bold');
% 1D
subplot(k1,k2,2);
plot(E(:,1), 'r-', 'LineWidth',.5);
hold on;
plot(F(:,1), 'b-', 'LineWidth',.5);
title({['(D) After 1D Alignment']});
xlabel('X', 'FontSize',12, 'FontWeight', 'bold');
ylabel('Y', 'FontSize',12, 'FontWeight', 'bold');
zlabel('Z', 'FontSize',12, 'FontWeight', 'bold');
end
end
Zain Khaliqhttps://nl.mathworks.com/matlabcentral/profile/authors/9629946-zain-khaliqtag:nl.mathworks.com,2005:Question/5009092020-01-18T21:57:20Z2020-01-18T22:21:57ZUnique Number Assignment To Each TimeHi,
I have a series of times in column 1. The times are 1.1, 1.1, 1.1, 1.2, 1.2, 1.2, 2.1, 2.1, 2.1 etc. I want to assign a unique number to each of these times. In order words, each time series should have its own number. Eg, all 1.1 should be assign the number 0, all 1.2 to the number 1 etc. A unique number to each series or repeating time. Any thoughts?
Thanks!Francis Kwofiehttps://nl.mathworks.com/matlabcentral/profile/authors/8298095-francis-kwofietag:nl.mathworks.com,2005:Question/5009042020-01-18T19:55:49Z2020-01-18T22:04:29ZEdge distortion when resampling a signalI have the follwing cosine signal that is sampled at rate fs = 32 Hz.
f = 30;
fs = 32;
dt = 1/fs;
t = -0.5:dt:0.5;
c = cos(2.*pi.*f.*t);
figure
plot (t,c)
I want to upsample it as follows:
figure
ty = linspace(-0.5,0.5,270)
y = resample(c,1003,123);
plot(ty,y)
But as you can see there is distrotion at the edge. Is there any way to avoid that?
Romiohttps://nl.mathworks.com/matlabcentral/profile/authors/10838202-romiotag:nl.mathworks.com,2005:Question/5008002020-01-17T19:54:13Z2020-01-18T21:56:18Zthis code is taking a lot of time to run, Is there anyway i can write this code efficiently and reduce runtime? I am trying to import data from multiple files in a folder
clc;clear;
testfiledir = 'C:\Users\bidgu\OneDrive\Desktop\manpower';
matfiles = dir(fullfile(testfiledir, '*.xlsm'));
nfiles = length(matfiles);
datafi = cell(nfiles);
for i = 1 :nfiles
% fid = fopen( fullfile(testfiledir, matfiles(i).name) );
datafi{i} = readtable(fullfile(testfiledir, matfiles(i).name));
% fclose(fid);
endPrajwal Venkateshhttps://nl.mathworks.com/matlabcentral/profile/authors/13333755-prajwal-venkateshtag:nl.mathworks.com,2005:Question/5008252020-01-18T00:12:32Z2020-01-18T21:49:18Zhow to obtain volume data from X,Y,Z,c data to use slice() function?If we have X,Y,Z,v data, how can I manage to get Volume data form in order to use slice function?
please check data (data.mat)
first column: x coordinate
second column: y coordinate
third column: z coordinate
fourth column: dataPhilippe Cornerhttps://nl.mathworks.com/matlabcentral/profile/authors/7103813-philippe-cornertag:nl.mathworks.com,2005:Question/5008672020-01-18T13:56:59Z2020-01-18T21:47:37ZMatlab gives no result when I use the ODE (Ordinary Differential Equations)When trying to find the symbolic solution in the following code, I got a warning and empty sym!
syms y(t) y0 Dy0
A=1;
B=2;
Dy = diff(y,t);
D2y = diff(y,t,2);
ode = diff(y,t,2)-A*(y)^2-B^2*y==0;
cond1 = y(0) == 1;
cond2 = Dy(1) == 0;
conds = [cond1 cond2];
ySol(t) = dsolve(ode,conds);
ySol = simplify(ySol, 'Steps',20)
disp(ySol(t))
Warning: Explicit solution could not be found.
> In dsolve (line 201)
In symbolic_Fun (line 11)
ySol(t) =
[ empty sym ]
[ empty sym ]
What was my mistake?
Please advise.Samer Atawnehhttps://nl.mathworks.com/matlabcentral/profile/authors/14055129-samer-atawnehtag:nl.mathworks.com,2005:Question/5006792020-01-17T01:37:32Z2020-01-18T21:47:27ZHow to add code in each cell of the GUI table?Hi guys I am working a secant method with GUI and I am a total beginner in matlab. I want to ask if it is possible to add code/formula in each cell of the table in GUI? What I want to happen is to automatically solve the linear equation after I press the 'Calculate' push button and the data will be shown on the table below. The picture of the gui is attached here, thanksDale Janry Serranohttps://nl.mathworks.com/matlabcentral/profile/authors/15292072-dale-janry-serranotag:nl.mathworks.com,2005:Question/5007962020-01-17T19:00:15Z2020-01-18T21:42:54Zsolving equation with if statementsHello
I am trying to solve the following equation given input time and values (y) vectors.
I tried the following
syms theta kappa alpha
if time < alpha
eqn = exp(-kappa*time)==y;
else
eqn = exp(-kappa)*exp(-theta*(time-alpha))==y;
end
vars = [theta kappa alpha];
S=solve(eqn);
but it raises an error...
Conversion to logical from sym is not possible.
I tried to convert alpha into double (i.e. double(alpha) ) in the if statement but it did not work...
Any suggestions?
the data look like :
antoinehttps://nl.mathworks.com/matlabcentral/profile/authors/6475725-antoinetag:nl.mathworks.com,2005:Question/5009062020-01-18T21:02:49Z2020-01-18T21:37:24ZInter-rater reliabilityHi,
I am trying to find out inter-rater reliability between 3 readers. The data is nominal. There were two categories used to grade the samples: FID denoted with 1 and AFID denoted with 0. I am not sure how to go about writing a code to determine inter rater reliabilty between these readers for this data. Namarta Kapilhttps://nl.mathworks.com/matlabcentral/profile/authors/15530631-namarta-kapiltag:nl.mathworks.com,2005:Question/5009082020-01-18T21:33:50Z2020-01-18T21:33:50ZHow to calculate the slope from geopraphical coordinates?Hi all,
I have installed a GPS logger on a vehicle, so I have extracted the geographcal coordinates in degree (longitude, latitude and elevation). I need to calculate the slope encountered by the vehicle. I came up with the following code, that is far from being good as you can see in the attached plot. How may I improve the results?
wgs84 = wgs84Ellipsoid('meters');
[gpsx,gpsy,gpsz] = geodetic2ecef(wgs84,Latitude,Longitude,Altitude);
slope=atand(diff(gpsz)./sqrt(diff(gpsx).^2+diff(gpsy).^2));
Thank you.
Best regards.
Michele Mattettihttps://nl.mathworks.com/matlabcentral/profile/authors/4391864-michele-mattettitag:nl.mathworks.com,2005:Question/202011-01-06T00:28:46Z2020-01-18T21:32:13ZHow do I make a desktop launcher for MATLAB in Linux?I don’t want to have to open a terminal window every time I want to launch MATLAB on Linux. I tried to make a Gnome launcher, but it does not seem to work. The command I gave was:
/usr/local/bin/matlab &
I see the process running, but now windows appear. What am I doing wrong?Ian Jessenhttps://nl.mathworks.com/matlabcentral/profile/authors/1597502-ian-jessentag:nl.mathworks.com,2005:Question/5008272020-01-18T00:19:15Z2020-01-18T21:21:48ZSelecting tables among 540 tables, based on a start and end dateHello all,
I have an x.mat cell which includes over 540 tables for 540 climate stations. In every 540 tables, there is a column named data (data is a wrong variable name for date). I want to have a code that selects every table that has a specific period from 1989 to 2018 and saves them in a new cell named x_selected.
I want to save the table if the start (1989) and end time (2018) are satisfied in the tables even if other years in between doesn't exist in it.
the following examples describe what I want:
for example, if one table (station) has only data from 2000 to 2018 so it is not going to save in x_selected because it hasn't data from 1989 to 2018. But if a table (station) has data for 1989 and 2018 (and not in between these two years) I want to save it in x_selected.
if a table has data for 2000 to 2003 I don't want it because the start time isn't 1989 and the end time isn't 2018.
if a table has data only for 2015 I don't want it because the time range 1989-2018 is not considered.
if a table has data from 1989 to 2018 but missed some years (like 2015, 2017) I want to save it because start time and end time are satisfied.
the above year is for example and may be different in the tables I just write them for example, what's important is start time (1989) and end time(2018).
x.mat is attached.
Thank you so much.Behzad Navidihttps://nl.mathworks.com/matlabcentral/profile/authors/15525777-behzad-naviditag:nl.mathworks.com,2005:Question/4172682018-09-03T12:00:36Z2020-01-18T21:01:05ZI found some error when installing MATLAB R2018a what should i do?This is error message alert on my screen when login to my account
"Error : unable to connect to host. sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target "Jakkaphan Whasphuttisithttps://nl.mathworks.com/matlabcentral/profile/authors/5455538-jakkaphan-whasphuttisittag:nl.mathworks.com,2005:Question/4962202019-12-12T01:03:27Z2020-01-18T20:59:17ZMatlab 2019b installer does not install on Mac OS CatalinaAfter upgrading to Mac OS Catalina, I have had troubles with Matlab 2019a. Unfortanetly, the installer for Matlab 2019b does not work either. Here is the error I get when I run the 2019b installer.
Error : unable to connect to host.
sun.security.validator.ValidatorException: PKIX path building failed:
sun.security.provider.certpath.SunCertPathBuilderException: unable to find
valid certification path to requested target
Should I remove the 2019a installation, before installing 2019b?Roozbeh Yousefzadehhttps://nl.mathworks.com/matlabcentral/profile/authors/5281720-roozbeh-yousefzadehtag:nl.mathworks.com,2005:Question/5009052020-01-18T20:57:53Z2020-01-18T20:57:53ZHow should I use "-fork" option in mclInitializeApplication in R2019b?Hi,
I saw the documents here: https://www.mathworks.com/help/compiler_sdk/cxx/mclinitializeapplication.html?searchHighlight=mclInitializeApplication&s_tid=doc_srchtitle showing that we can use option "-fork" for mclInitializeApplication when initialize a Matlab Runtime Instance in R2019b but I cannot find any furthur explaination regarding this option.
And when I tried to use following code to initialize the mcr:
const char* mcr_options[] = {"-fork"};
if (!mclInitializeApplication(mcr_options, 1)) {
std::cerr << "Could not initialize the application properly" << std::endl;
return -1;
} else {
std::cout << "Done mclInitializeApplication" << std::endl;
}
I keep receive this warning: "Warning: Unrecognized command line option: fork."
I wonder if this option is truely implemented inside R2019b. If so, how can I make it work properly?
ThanksWENYU ZHANGhttps://nl.mathworks.com/matlabcentral/profile/authors/17313070-wenyu-zhangtag:nl.mathworks.com,2005:Question/947242011-05-16T15:32:00Z2020-01-18T20:56:28ZHow can I open my current Simulink models in previous versions of Simulink?For example, I would like to know if my Simulink 3.0 models will load back into Simulink 2.2. When I try to bring models that were saved in Simulink 3.0 back into Simulink 2.2, I receive a number of warning messages, and then the model does not appear properly (blank). In some cases the model does not open at all.
An example of the warnings in Simulink 2.0:
ERROR: Warning: Loading model 'modelname' generated with an earlier version (2.09) of SIMULINK.
Warning: vers.mdl, line 10: block_diagram does not have a parameter named 'PaperType'.
Warning: vers.mdl, line 11: block_diagram does not have a parameter named 'PaperUnits'.
Warning: vers.mdl, line 46: block_diagram does not have a parameter named 'SimulationMode'.
Warning: vers.mdl, line 49: block_diagram does not have a parameter named 'RTWRetainRTWFile'.
Warning: vers.mdl, line 53: block_diagram does not have a parameter named 'ExtModeMexFile'.
Warning: vers.mdl, line 54: block_diagram does not have a parameter named 'ExtModeBatchMode'.
Warning: vers.mdl, line 78: block_diagram does not have a parameter named 'LineDefaults'.
Warning: vers.mdl, line 79: block_diagram does not have a parameter named 'FontName'.
Warning: vers.mdl, line 80: block_diagram does not have a parameter named 'FontSize'.
Warning: vers.mdl, line 81: block_diagram does not have a parameter named 'FontWeight'.
Warning: vers.mdl, line 82: block_diagram does not have a parameter named 'FontAngle'.
When I try to bring a model from Simulink 2.2 to 2.1, I receive similiar warnings, but the model does appear.MathWorks Support Teamhttps://nl.mathworks.com/matlabcentral/profile/authors/4622813-mathworks-support-teamtag:nl.mathworks.com,2005:Question/5008922020-01-18T17:19:48Z2020-01-18T20:34:40ZPossible to model Solute Transport equation with PDE Toolbox?I am fairly new to MATLAB, and have used it only occasionally. I followed along with this 3D FEM Matlab video. I now wish to solve my equation using the same FEM method and PDE toolbox, but I am struggling with where to begin.
Is it correct that if using parabolic form below:
d= 1
c=D (I would define this in the code)
a= ?????
Would it be possible to solve this equation using finite element methods in Matlab? I'm struggling to put it into Parabolic form with the 3 dimensions, and the final part.
The solute transport equation is quite long and overwhelming.
Any help appreciated many thanksGreg Murphyhttps://nl.mathworks.com/matlabcentral/profile/authors/11476671-greg-murphytag:nl.mathworks.com,2005:Question/4997832020-01-10T16:00:51Z2020-01-18T20:24:14ZCalculating results for Partial SumsMy question is:
Calculate the result and absolute error for each partial sum: N = 10, 160, and 640. You should use for-loops and not commands like symsum.
I keep on getting weird answes in Matlab and was wondering if my code was missing something:
%(a) Calculate the result and absolute error for each partial sum: N = 10, 160, and 640.
sum=0;
for N=[10 160 640]
for n=1:1:N
y=1/n^2
end
sum=sum+1
error=((pi^2)/6)-sum
end
disp(sum)
PLEASE DO NOT GIVE ME THE COMPLETE ANSWER TO THE QUESTION. I WOULD JUST LIKE AN EXPLANATION OF WHAT I AM DOING WRONG.Kyle Donkhttps://nl.mathworks.com/matlabcentral/profile/authors/17189528-kyle-donktag:nl.mathworks.com,2005:Question/5008572020-01-18T11:53:14Z2020-01-18T20:22:55Zhow make the plot continuous ? So I want to make a plot of PWM ,how ever the plot commant make it wrong becouse it conects the dots in the wrong places . for exmaple , I want to make PWM of 10 Hz when the duty cycle is 60% . so this is the code :
clc;clear all;
vector_ones=ones(1,10);
for i=1:10
if(6<i)
vector_ones(i)=0;
end
end
figure(1);
plot(1:10,vector_ones,'red');
figure(2);
stem(1:10,vector_ones,'red');
as you can see in figure 2 the stem plot 0-6 I get ones and after 7 it all zeors :
and when I use regular plot insted of stem there is diaganole between 6 and 7,the question how can I make it like the stem plot but continuous ?
tomer polskyhttps://nl.mathworks.com/matlabcentral/profile/authors/12906803-tomer-polskytag:nl.mathworks.com,2005:Question/5008622020-01-18T12:56:50Z2020-01-18T20:12:37ZPerforming operations on non-uniform dataI want to perform subtraction operation on the second column of the below datapoints-
I want this operation to be performed on every 20 minutes. Basically, I am trying to find out log returns at every 20 minutes. However, since my data is not uniform, i am not able to write a general code to do the same. For example, i start my calculations at 00:00:00 and then go to 00:20:00 and my code works. However, when it goes to 01:00:00, it does not find any data. Also it does not find any data at 01:20:00 or 01:40:00.
%Original dataset
1512604800 '07-Dec-2017 00:00:00' 14090
1512604801 '07-Dec-2017 00:00:01' 14090
1512604803 '07-Dec-2017 00:00:03' 14090
1512604804 '07-Dec-2017 00:00:04' 14090
1512604805 '07-Dec-2017 00:00:05' 14090
1512604807 '07-Dec-2017 00:00:07' 14090
1512604808 '07-Dec-2017 00:00:08' 14090
1512604809 '07-Dec-2017 00:00:09' 14090
1512604810 '07-Dec-2017 00:00:10' 14090
1512604812 '07-Dec-2017 00:00:12' 14090
1512604813 '07-Dec-2017 00:00:13' 14090
1512604814 '07-Dec-2017 00:00:14' 14090
1512604815 '07-Dec-2017 00:00:15' 14090.5
1512604816 '07-Dec-2017 00:00:16' 14098
1512604817 '07-Dec-2017 00:00:17' 14098.98
1512604818 '07-Dec-2017 00:00:18' 14099
1512604820 '07-Dec-2017 00:00:20' 14098.99
1512604821 '07-Dec-2017 00:00:21' 14099
1512604822 '07-Dec-2017 00:00:22' 14098.99
1512604823 '07-Dec-2017 00:00:23' 14099
1512604825 '07-Dec-2017 00:00:25' 14099
1512604826 '07-Dec-2017 00:00:26' 14099
%Reduced dataset (Just for understanding the 20 min datapoints)
1512604800 '07-Dec-2017 00:00:00' 14090
1512606000 '07-Dec-2017 00:20:00' 14369.99
1512607206 '07-Dec-2017 00:40:06' 14389.99
1512608402 '07-Dec-2017 01:00:02' 14370.03
1512609601 '07-Dec-2017 01:20:01' 14388
1512610801 '07-Dec-2017 01:40:01' 14399.48
1512612000 '07-Dec-2017 02:00:00' 14361.01
1512613200 '07-Dec-2017 02:20:00' 13900
1512614400 '07-Dec-2017 02:40:00' 14079
1512615600 '07-Dec-2017 03:00:00' 13974.03
1512616804 '07-Dec-2017 03:20:04' 14082.94
1512618001 '07-Dec-2017 03:40:01' 13976
1512619201 '07-Dec-2017 04:00:01' 13911.8
1512620400 '07-Dec-2017 04:20:00' 14099.985
%I need these returns (have calcualted on excel sheet)
1512604800 '07-Dec-2017 00:00:00' 14090 Desired_returns
1512606000 '07-Dec-2017 00:20:00' 14369.99 279.99
1512607206 '07-Dec-2017 00:40:06' 14389.99 20
1512608402 '07-Dec-2017 01:00:02' 14370.03 -19.96
1512609601 '07-Dec-2017 01:20:01' 14388 17.97
1512610801 '07-Dec-2017 01:40:01' 14399.48 11.48
1512612000 '07-Dec-2017 02:00:00' 14361.01 -38.47
1512613200 '07-Dec-2017 02:20:00' 13900 -461.01
1512614400 '07-Dec-2017 02:40:00' 14079 179
1512615600 '07-Dec-2017 03:00:00' 13974.03 -104.97
1512616804 '07-Dec-2017 03:20:04' 14082.94 108.91
1512618001 '07-Dec-2017 03:40:01' 13976 -106.94
1512619201 '07-Dec-2017 04:00:01' 13911.8 -64.2
1512620400 '07-Dec-2017 04:20:00' 14099.985 188.185
%Code
startDate = final_data(1,1);
interval = 20;
returnsForDay = [];
previousValue = 14389.99;
j=1;
tempDateArray = [];
flag = 0;
while j<=(length(final_data))
startdatetemp = final_data(j,1);
CurrentDate = datestr( unixtime_to_datenum( startdatetemp ) );
CurrentDateAfterInc = datestr( unixtime_to_datenum( startDate ) );
if(startDate == startdatetemp)
price_var = final_data(j,2);
fprintf('Previous value when datesat are equal %d',previousValue);
if(j==1)
previousValue = price_var;
end
newcol = length(returnsForDay);
j
returnsForDay(newcol + 1) = price_var - previousValue;
returnsForDay
previousValue = price_var;
flag = 1;
j=j+1;
elseif(startDate > startdatetemp)
if(flag == 0)
previousValue = final_data(j,2);
end
continue
elseif(startDate < startdatetemp)
newcol = length(returnsForDay);
fprintf('Previous value when datesat are not equal %d',previousValue);
if(flag ==1)
fprintf('am here');
returnsForDay(newcol + 1) = final_data(j,2) - previousValue;
else
if(j == 2)
returnsForDay(newcol + 1) = previousValue - final_data(j-1,2);
returnsForDay
previousValue = final_data(j-1,2);
else
returnsForDay(newcol + 1) = previousValue - final_data(j-2,2);
returnsForDay
previousValue = final_data(j-2,2);
end %enf of small if statement
end
end %end of bigger if statement
Converted_dates = datestr( unixtime_to_datenum( startDate ) );
startdateTEMP = posixtime(datetime(Converted_dates) + minutes(00:interval:interval));
startDate = startdateTEMP(1,2);
end
Harsh Robhttps://nl.mathworks.com/matlabcentral/profile/authors/15148505-harsh-robtag:nl.mathworks.com,2005:Question/5008512020-01-18T11:09:29Z2020-01-18T20:09:13ZLimiting mouseclick event to current Axes in App DesignerHi, I am trying to get the mouselocation on an axes - 'app.UIAxes' (using app designer).
delete(findobj(app.UIAxes, 'Marker', '*')); %DElete previous marker
z=app.UIAxes.CurrentPoint;
x=z(1,1); y=z(1,2);
hold(app.UIAxes,'on');
plot(app.UIAxes,x,y,'b*');
hold(app.UIAxes,'off');
app.xy=[x,y]; %Save value so can access later
However, as I also have 2 other UIAxes (app.UIAxes2 & app.UIAxes3), whenever I click on any of them, it invokes the fucntion above and plots a point on the UIAxes.
How can I limit this to just the UIAxesJasonhttps://nl.mathworks.com/matlabcentral/profile/authors/1217570-jasontag:nl.mathworks.com,2005:Question/5008902020-01-18T17:14:55Z2020-01-18T19:52:12ZConverting cell array to structHello,
I am trying to convert a cell array "zq" shown below:
into a struct, with this code:
fields_1 = {'individualStiffnessMatrix'}; % convert cell to struct
zq_1 =cell2struct(zq,fields_1,2);
but I am getting this error, does any one know about it
" Error using cell2struct
Number of field names must match number of fields in new structure."
I just want two fields in struct like a 2x1 struct not more
hamzah khanhttps://nl.mathworks.com/matlabcentral/profile/authors/7944651-hamzah-khantag:nl.mathworks.com,2005:Question/4977212019-12-22T13:32:28Z2020-01-18T19:42:47Zmerge images from diffrent folderHi,I need a code that merges 2 folders Jpg images that inside each of the folders 120 images,the format that I need to merge is on by on (1 from folder1 by 1 from folder2, 2 from folder 1 by 2 from folder 2, so on.) and pastes the merged images into a separate folder(new path).
Thank for help.Hamid Ebrahimihttps://nl.mathworks.com/matlabcentral/profile/authors/17138242-hamid-ebrahimitag:nl.mathworks.com,2005:Question/5008342020-01-18T05:11:33Z2020-01-18T19:41:33ZHow to generate a symmetric Toeplitz matrix? How to generate a symmetric Toeplitz matrix in a specific range, say [-pi , pi]?Asma Ahmedhttps://nl.mathworks.com/matlabcentral/profile/authors/5904670-asma-ahmedtag:nl.mathworks.com,2005:Question/5008982020-01-18T18:14:08Z2020-01-18T19:32:22Z3D Plotting in matlabI have got a function after integration in Matlab, f($\theta$,$g$) which is a complex function. I would like to get 3D plot the this function with respect to $\theta$ and g, where $g$ positive integer runs from 0 and $\theta $ runs from 0 to $\pi$. The function is very large and complicated one. Pl hep me to plot this.P Maityhttps://nl.mathworks.com/matlabcentral/profile/authors/17312484-p-maitytag:nl.mathworks.com,2005:Question/5009032020-01-18T19:14:49Z2020-01-18T19:14:49ZMatlab Coder Windows -> Linux cross-compilationVersion: Matlab 2019b
Task: from Windows compile Linux static library (.a) to be used in Android application.
Current state: on Windows Matlab Coder allows generation of .lib, .dll only.
I saw there are threads for cross-compilation, does anyone made it work and can provide detailed instruction?Alexsander Shafirhttps://nl.mathworks.com/matlabcentral/profile/authors/11837315-alexsander-shafirtag:nl.mathworks.com,2005:Question/5008832020-01-18T16:22:09Z2020-01-18T19:11:38Zdeclaring multi global variables with simulink model1Hello every one
please I need some boday to help me to solve an error that bub-up to me and I could not solve it.
I am bulding a model predictive controller using the differencail equation models for plant and my main function which is the controller statements in a matlab function block, I also used the an other file to declare the variables .
(this examlpe from the PREDICTIVE CONTROL OF POWER CONVERTERS AND ELECTRICAL DRIVES book - excersise 1 Predictive Control Simulation – Three-Phase Inverter)
the code has some golbal varaibles that are declared globaly in both in the main function (in the matlab fun block) and in the file that I declared the rest of the local variables.
I connected all componants to each other but I have the error that need the glabal varaible to be declared?
I inclouded the code in the attachemts below
this is the error:
Global declaration not resolved to a Data Store Memory block registered via the Ports and Data Manager.
Function 'MATLAB Function' (#23.513.514), line 15, column 6:
"v"
Launch diagnostic report.
Component:MATLAB Function | Category:Coder error
Global declaration not resolved to a Data Store Memory block registered via the Ports and Data Manager.
Function 'MATLAB Function' (#23.524.525), line 15, column 17:
"L"
Launch diagnostic report.
Component:MATLAB Function | Category:Coder error
Global declaration not resolved to a Data Store Memory block registered via the Ports and Data Manager.
Function 'MATLAB Function' (#23.526.528), line 15, column 19:
"Ts"
Launch diagnostic report.
Component:MATLAB Function | Category:Coder error
Global declaration not resolved to a Data Store Memory block registered via the Ports and Data Manager.
Mohamedhttps://nl.mathworks.com/matlabcentral/profile/authors/4994557-mohamedtag:nl.mathworks.com,2005:Question/5009022020-01-18T18:51:58Z2020-01-18T18:51:58ZRate Maximization- Optimization ProblemI am trying to implement following attached problem using OPTI toolbox but I am unable to write objective function and constraints in matrix form
SONAIN JAMILhttps://nl.mathworks.com/matlabcentral/profile/authors/13195753-sonain-jamiltag:nl.mathworks.com,2005:Question/5008232020-01-17T23:46:10Z2020-01-18T18:50:01ZHow to prevent addition from showing up in command windowI ran some code and am having trouble with the results of the code come out like this:
995
996
997
998
999
1000
How do I just get 1000 instead of all of the numbers? I have suppressed literally everything in the code.Kyle Donkhttps://nl.mathworks.com/matlabcentral/profile/authors/17189528-kyle-donktag:nl.mathworks.com,2005:Question/5008932020-01-18T17:20:29Z2020-01-18T18:32:28ZHow do I find the mean of a binary set for each value of no.1 to7I have a vector row of 5,000 random no.s 1 to 7. I have a vector row of 5,000 1's and 0's as a second vector row. (This represents 5,000 tirials, where every time the random number was > 4, the machine chose 1, otherwise 0). I have put both vectors together in a matrix/array with the values on top row and the binaries on the second row. I have to calcualte the mean of the responses for each of the values. How do I do this please? I am beginner level and need my variables spelled out, to understand them. I think I use accumarray and mean but not sure how to compile the coding.Tracey Rochesterhttps://nl.mathworks.com/matlabcentral/profile/authors/13905356-tracey-rochestertag:nl.mathworks.com,2005:Question/5009012020-01-18T18:30:25Z2020-01-18T18:30:25ZIs there a problem in for loop, why is dfi not correctly calculate?Here is my code:
N=utc_tai(year,month,day,hour,min,sec);
JDutc=greg2julian(year,month,day,hour,min,sec);
JDtt=JDutc+(N+32.184)/86400;
T=(JDtt-2451545)/36525; % T the time expressed in Julian centuries
eps=(23+26/60+21.448/3600)-(46.8150/3600)*T-(0.00059/3600)*(T^2)+(0.001813/3600)*(T^3);
nut1980= [
% l l' F D om Period A0j A1j B0j B1j
% (days) (10^-4'') (10^-4'')
0 0 0 0 1 -6798.4 -171996.0 -174.2 92025.0 8.9;
0 0 2 -2 2 182.6 -13187.0 -1.6 5736.0 -3.1;
0 0 2 0 2 13.7 -2274.0 -0.2 977.0 -0.5;
0 0 0 0 2 -3399.2 2062.0 0.2 -895.0 0.5;
0 -1 0 0 0 -365.3 -1426.0 3.4 54.0 -0.1;
1 0 0 0 0 27.6 712.0 0.1 -7.0 0.0;
0 1 2 -2 2 121.7 -517.0 1.2 224.0 -0.6;
0 0 2 0 1 13.6 -386.0 -0.4 200.0 0.0;
1 0 2 0 2 9.1 -301.0 0.0 129.0 -0.1;
0 -1 2 -2 2 365.2 217.0 -0.5 -95.0 0.3;
-1 0 0 2 0 31.8 158.0 0.0 -1.0 0.0;
0 0 2 -2 1 177.8 129.0 0.1 -70.0 0.0;
-1 0 2 0 2 27.1 123.0 0.0 -53.0 0.0;
1 0 0 0 1 27.7 63.0 0.1 -33.0 0.0;
0 0 0 2 0 14.8 63.0 0.0 -2.0 0.0;
-1 0 2 2 2 9.6 -59.0 0.0 26.0 0.0;
-1 0 0 0 1 -27.4 -58.0 -0.1 32.0 0.0;
1 0 2 0 1 9.1 -51.0 0.0 27.0 0.0;
-2 0 0 2 0 -205.9 -48.0 0.0 1.0 0.0;
-2 0 2 0 1 1305.5 46.0 0.0 -24.0 0.0;
0 0 2 2 2 7.1 -38.0 0.0 16.0 0.0;
2 0 2 0 2 6.9 -31.0 0.0 13.0 0.0;
2 0 0 0 0 13.8 29.0 0.0 -1.0 0.0;
1 0 2 -2 2 23.9 29.0 0.0 -12.0 0.0;
0 0 2 0 0 13.6 26.0 0.0 -1.0 0.0;
0 0 2 -2 0 173.3 -22.0 0.0 0.0 0.0;
-1 0 2 0 1 27.0 21.0 0.0 -10.0 0.0;
0 2 0 0 0 182.6 17.0 -0.1 0.0 0.0;
0 2 2 -2 2 91.3 -16.0 0.1 7.0 0.0;
-1 0 0 2 1 32.0 16.0 0.0 -8.0 0.0;
0 1 0 0 1 386.0 -15.0 0.0 9.0 0.0;
1 0 0 -2 1 -31.7 -13.0 0.0 7.0 0.0;
0 -1 0 0 1 -346.6 -12.0 0.0 6.0 0.0;
2 0 -2 0 0 -1095.2 11.0 0.0 0.0 0.0;
-1 0 2 2 1 9.5 -10.0 0.0 5.0 0.0;
1 0 2 2 2 5.6 -8.0 0.0 3.0 0.0;
0 -1 2 0 2 14.2 -7.0 0.0 3.0 0.0;
0 0 2 2 1 7.1 -7.0 0.0 3.0 0.0;
1 1 0 -2 0 -34.8 -7.0 0.0 0.0 0.0;
0 1 2 0 2 13.2 7.0 0.0 -3.0 0.0;
-2 0 0 2 1 -199.8 -6.0 0.0 3.0 0.0;
0 0 0 2 1 14.8 -6.0 0.0 3.0 0.0;
2 0 2 -2 2 12.8 6.0 0.0 -3.0 0.0;
1 0 0 2 0 9.6 6.0 0.0 0.0 0.0;
1 0 2 -2 1 23.9 6.0 0.0 -3.0 0.0;
0 0 0 -2 1 -14.7 -5.0 0.0 3.0 0.0;
0 -1 2 -2 1 346.6 -5.0 0.0 3.0 0.0;
2 0 2 0 1 6.9 -5.0 0.0 3.0 0.0;
1 -1 0 0 0 29.8 5.0 0.0 0.0 0.0;
1 0 0 -1 0 411.8 -4.0 0.0 0.0 0.0;
0 0 0 1 0 29.5 -4.0 0.0 0.0 0.0;
0 1 0 -2 0 -15.4 -4.0 0.0 0.0 0.0;
1 0 -2 0 0 -26.9 4.0 0.0 0.0 0.0;
2 0 0 -2 1 212.3 4.0 0.0 -2.0 0.0;
0 1 2 -2 1 119.6 4.0 0.0 -2.0 0.0;
1 1 0 0 0 25.6 -3.0 0.0 0.0 0.0;
1 -1 0 -1 0 -3232.9 -3.0 0.0 0.0 0.0;
-1 -1 2 2 2 9.8 -3.0 0.0 1.0 0.0;
0 -1 2 2 2 7.2 -3.0 0.0 1.0 0.0;
1 -1 2 0 2 9.4 -3.0 0.0 1.0 0.0;
3 0 2 0 2 5.5 -3.0 0.0 1.0 0.0;
-2 0 2 0 2 1615.7 -3.0 0.0 1.0 0.0;
1 0 2 0 0 9.1 3.0 0.0 0.0 0.0;
-1 0 2 4 2 5.8 -2.0 0.0 1.0 0.0;
1 0 0 0 2 27.8 -2.0 0.0 1.0 0.0;
-1 0 2 -2 1 -32.6 -2.0 0.0 1.0 0.0;
0 -2 2 -2 1 6786.3 -2.0 0.0 1.0 0.0;
-2 0 0 0 1 -13.7 -2.0 0.0 1.0 0.0;
2 0 0 0 1 13.8 2.0 0.0 -1.0 0.0;
3 0 0 0 0 9.2 2.0 0.0 0.0 0.0;
1 1 2 0 2 8.9 2.0 0.0 -1.0 0.0;
0 0 2 1 2 9.3 2.0 0.0 -1.0 0.0;
1 0 0 2 1 9.6 -1.0 0.0 0.0 0.0;
1 0 2 2 1 5.6 -1.0 0.0 1.0 0.0;
1 1 0 -2 1 -34.7 -1.0 0.0 0.0 0.0;
0 1 0 2 0 14.2 -1.0 0.0 0.0 0.0;
0 1 2 -2 0 117.5 -1.0 0.0 0.0 0.0;
0 1 -2 2 0 -329.8 -1.0 0.0 0.0 0.0;
1 0 -2 2 0 23.8 -1.0 0.0 0.0 0.0;
1 0 -2 -2 0 -9.5 -1.0 0.0 0.0 0.0;
1 0 2 -2 0 32.8 -1.0 0.0 0.0 0.0;
1 0 0 -4 0 -10.1 -1.0 0.0 0.0 0.0;
2 0 0 -4 0 -15.9 -1.0 0.0 0.0 0.0;
0 0 2 4 2 4.8 -1.0 0.0 0.0 0.0;
0 0 2 -1 2 25.4 -1.0 0.0 0.0 0.0;
-2 0 2 4 2 7.3 -1.0 0.0 1.0 0.0;
2 0 2 2 2 4.7 -1.0 0.0 0.0 0.0;
0 -1 2 0 1 14.2 -1.0 0.0 0.0 0.0;
0 0 -2 0 1 -13.6 -1.0 0.0 0.0 0.0;
0 0 4 -2 2 12.7 1.0 0.0 0.0 0.0;
0 1 0 0 2 409.2 1.0 0.0 0.0 0.0;
1 1 2 -2 2 22.5 1.0 0.0 -1.0 0.0;
3 0 2 -2 2 8.7 1.0 0.0 0.0 0.0;
-2 0 2 2 2 14.6 1.0 0.0 -1.0 0.0;
-1 0 0 0 2 -27.3 1.0 0.0 -1.0 0.0;
0 0 -2 2 1 -169.0 1.0 0.0 0.0 0.0;
0 1 2 0 1 13.1 1.0 0.0 0.0 0.0;
-1 0 4 0 2 9.1 1.0 0.0 0.0 0.0;
2 1 0 -2 0 131.7 1.0 0.0 0.0 0.0;
2 0 0 2 0 7.1 1.0 0.0 0.0 0.0;
2 0 2 -2 1 12.8 1.0 0.0 -1.0 0.0;
2 0 -2 0 1 -943.2 1.0 0.0 0.0 0.0;
1 -1 0 -2 0 -29.3 1.0 0.0 0.0 0.0;
-1 0 0 1 1 -388.3 1.0 0.0 0.0 0.0;
-1 -1 0 2 1 35.0 1.0 0.0 0.0 0.0;
0 1 0 1 0 27.3 1.0 0.0 0.0 0.0;
];
% Mean arguments of luni-solar motion
% l mean anomaly of the Moon
% ldot mean anomaly of the Sun
% F mean argument of latitude
% D mean longitude elongation of the Moon from the Sun
% om mean longitude of the ascending lunar node
l=485866.733/3600+(1325*360+715922.633/3600)*T+(31.310/3600)*(T^2)+(0.064/3600)*(T^3);
ldot=1287099.804/3600+(99*360+1292581.224/3600)*T-(0.577/3600)*(T^2)+(0.012/3600)*(T^3);
F=335778.877/3600+(1342*360+295263.137/3600)*T-(13.257/3600)*(T^2)+(0.011/3600)*(T^3);
D=1072261.307/3600+(1236*360+1105601.328/3600)*T-(6.891/3600)*(T^2)+(0.019/3600)*(T^3);
om=450160.280/3600-(5*360+482890.539/3600)*T+(7.455/3600)*(T^2)+(0.008/3600)*(T^3);
dfi=0;
deps=0;
for j=1:length(nut1980)
for i=1:5
angle=(nut1980(j,i)*l+nut1980(j,i)*ldot+nut1980(j,i)*F+nut1980(j,i)*D+nut1980(j,i)*om);
end
dfi=dfi+((nut1980(j,7)*(10^(-4))/3600)+(nut1980(j,8)*(10^(-4))/3600)*T)*sin(angle);
deps=deps+((nut1980(j,9)*(10^(-4))/3600)+(nut1980(j,10)*(10^(-4))/3600)*T)*cos(angle);
end
edot=eps+deps;
I try to write a function calculating nutation iau1980 model angles. In this time(2018,12,20,12,00,00) dfi and deps are not correctly.Function calculate the dfi as a 0.000995986751157502 but value should be -0.00436247265183269. I think problem in for loops becase there is no problem in converted time but I did not find the problem is where. Is the problem in loops?Zeynep Miray Ertunçhttps://nl.mathworks.com/matlabcentral/profile/authors/16557052-zeynep-miray-ertunctag:nl.mathworks.com,2005:Question/5008992020-01-18T18:20:52Z2020-01-18T18:25:23Zx greater than y by some valueHi!
I have a problem with the syntax, I want to write an if loop that: if x is greater than y by 10 then .. I only know how to write that x is greater than y and the action, but how to write that is 10 greater?
The solution is probably easy but I have no idea ..
Thank you for your help!Carolinehttps://nl.mathworks.com/matlabcentral/profile/authors/12562252-carolinetag:nl.mathworks.com,2005:Question/5009002020-01-18T18:23:01Z2020-01-18T18:23:01ZWhat block is input in Vstab of excitation systemWe are simulating a hydro power plant and are stuck at the input to the Vstab of Excitation system Block. What is this block?Prakhar Pandeyhttps://nl.mathworks.com/matlabcentral/profile/authors/16389520-prakhar-pandeytag:nl.mathworks.com,2005:Question/5008962020-01-18T18:08:04Z2020-01-18T18:18:59Zplotting ode warning with nor plot returned
Trying to plot both of these ODEs against each other.
he error that is being returned is.
Warning: Error updating ParameterizedFunctionLine.
The following error was reported evaluating the function in FunctionLine update: Unable to convert expression into double array.
and the code is.
syms A(t) B(t)
N = 1000;
gamma = 0.1;
beta = 0.95;
eqns = [diff(A,t) == -beta*(B/N)*A+gamma*B, diff(B,t) == beta*(B/N)*(N-B)-gamma*B];
S = dsolve(eqns);
fplot(A,B)
jghttps://nl.mathworks.com/matlabcentral/profile/authors/12044418-jgtag:nl.mathworks.com,2005:Question/4467202019-02-24T15:58:16Z2020-01-18T18:18:54Zhow to find the optimal inputs values of neural network that can give optimal value of predicted outputDear All;
if i built a neural network model or any other black box models to predict an output value from a set of input value, then i need to find the values of the inputs that can yeild the optimal value of the predcited output , how can we do that ?can we run the stadrard optimization techniques? or shall we use search algorthim such as GA ? How can we do that in MATLAB? Mustafa Al-Nasserhttps://nl.mathworks.com/matlabcentral/profile/authors/3290849-mustafa-al-nassertag:nl.mathworks.com,2005:Question/3864932018-03-05T21:40:28Z2020-01-18T18:16:57ZRMSE between two variablesHello, I am really new at matlab. I am trying to create a sub-function that has an input of two vectors and output the RMSE between the values in the vectors. Anyone can help? I would love to understand step by step.
thanks to anybody that can help!!silvia battistellahttps://nl.mathworks.com/matlabcentral/profile/authors/12136332-silvia-battistella