Indexing column of excel from outside the function in matlab

I want to call my function by passing the inputs that are the Excel’s column names.
For example consider the following command xlsread(data,'name:name');to be inside the function and I want to call the function by passing the name like the following:


But this gives me error message since A is not defined. I have tried doing the following


This also give me error message. Can anyone tell me how to pass the character to xlsread inside the function.

All topic

How can I create a function that prints out the number of deletions it has to make to remove char that are the same in a string?

This is the assignment. How can I make this?

Problem 1.1 : String Cleanup
You have been provided with a string s. Your task is to remove any matching adjacent characters and return the minimum number of deletions required to achieve this.

For example, here below are the wanted output:
AAAAAA return 5
ABABABABA return 0

So I don’t want to count all the deletions of letters that are repeated in a string, only the one’s that are next to each other

All topic

Inserting a return statement in a function that prints the desired stair output in Python 3

My function is as follows:-
def steps(input_value):
for input_value in range(1, input_value + 1):
for j in range(1, input_value + 1):
print(” “,end=” “)
print(str(j) * 3)
I am able to get the correct step output using the print statements but I’m clueless about where to place the return statement so as not to return a None value. The results of my submission are as below:-

We found a few things wrong with your code.

We tested your code with num_steps = 3. We expected steps to return the str
“. However, it returned the NoneType None.

All topic

discuss about the differentiability of $g(x)=|f(x)|$, where $f$ is a differentiable function

I want to discuss about the differentiability of $g(x)=|f(x)|$, where $f$ is a differentiable function

Example 1

Take $f(x)=|x|$, function is clearly not differentiable at $x=0$.
enter image description here

Example 2

Take $f(x)=|sin(x)|$, function is clearly not differentiable at the point $x=npi$

enter image description here

After taking few more examples like $|x-1|, |cos(x)|$, it always seems to be the case that $|f(x)|$ is not differentiable at the points where $f(x)=0$

Observation: One thing is common in all the examples that some portion of $f(x)$ lies below $x$ axis.
So I took another example

$f(x)=x^2$ but $|f(x)|$ is differentiable at the point where $f(x)=0$

Question 1:

Am I right in concluding that we can not just say in general setting that $|f(x)|$ is not differentiable at the points where $f(x)=0$?

When can we(I mean under what conditions can we )conclude that $|f(x)|$ is differentiable at points where $f(x)=0$. My hypothesis is that graph of $f$ should lie below $x$ axis.

Question 2:

Let $f(x)$ and $g(x)$ be two differentiable function, when can we conclude that $|f(x)|+|g(x)|$ is not differentiable at the points where $f(x)=0$ and $g(x)=0$

Example $|sin(2-x)|+ |cos(x)| $ are not differentiable at $x=2+2pi, x=(2n+1)frac{k}{2}$

All topic

Generating SARIMA data and using it to evaluate the accuracy of the `predict` function, but getting some weird plots

I have written the following code to generate 500 data points from a $SARIMA$ model, use $400$ as training data and then predict the following $100$, while estimating the model with AIC. It appeared to me that I did everything correctly as I could see the AIC correctly choosing the model with certain phi values, etc. etc., however my plot outputs for the estimations is very very dense and incomprehensible and I’m not sure why. I checked the number of data points, the window size, etc. and am not sure what I have done wrong in my implementation.


#generate data
sdat1<- sarima.Sim(n=500, period=12, model = list(order = c(1,0,0), ar=0.5),list(order= c(1,0,0), ar = 0.5))
#procure training data <- window(sdat1, start=1, end=400)

#candidate models
op1 <- arima(, order=c(0,0,0), list(order= c(0,1,0)))
op2 <- arima(, order=c(1,0,0), list(order= c(1,0,1)))
op3 <- arima(, order=c(1,0,0), list(order= c(0,2,0)))
op4 <- arima(, order=c(0,1,0), list(order= c(0,0,0)))
op5 <- arima(, order=c(1,0,1), list(order= c(0,0,0)))
op6 <- arima(, order=c(1,0,0), list(order= c(1,0,0)))

models <- c(op1,op2,op3,op4,op5,op6)
models.AIC <- c(op1$aic,op2$aic,op3$aic,op4$aic,op5$aic,op6$aic) = NULL
if (min(models.AIC) == op1$aic){
} else if (min(models.AIC) == op2$aic){
} else if (min(models.AIC) == op3$aic){
} else if (min(models.AIC) == op4$aic){
} else if (min(models.AIC) == op5$aic){ 
} else if (min(models.AIC) == op6$aic){
modpred <- predict(, n.ahead=100)
vld.data1<-  sdat1[401:500]
plot.ts(sdat1, ylim=c(floor(min(sdat1)),ceiling(max(sdat1))))
plot.ts(sdat1, xlim=c(0,400),ylim=c(floor(min(sdat1)),ceiling(max(sdat1)))) 
lines(modpred$pred, col='blue')
lines(modpred$pred-(1.96*modpred$se), col='red')
lines(modpred$pred+(1.96*modpred$se), col='red')

enter image description here

All topic

Why isn’t sinon replacing the actual function call?

My function is:

const PhoneNumber = require('awesome-phonenumber');
const twilio = require('twilio')(process.env.TWILIO_ACCOUNT_SID, process.env.TWILIO_AUTH_TOKEN);
const { twiml } = require('twilio');

exports.incoming = (requestBody) => {
  const MessagingResponse = twiml.MessagingResponse;
  const VoiceResponse = twiml.VoiceResponse;
  const pn = new PhoneNumber(requestBody.Body, 'US');
    return global.db.Conference.create({})
      .then((dbCreate) => {
        conferenceId =;
        // Call originator
        return twilio.calls.create({
          to: requestBody.From,
          from: requestBody.To,
          url: `${process.env.API_URL}/calls/conference?id=${conferenceId}`

My test is:

const _ = require('lodash');
const sinon = require('sinon');
const twilio = require('twilio')(process.env.TWILIO_ACCOUNT_SID, process.env.TWILIO_AUTH_TOKEN);
const { twiml } = require('twilio');

const SmsController = require('../../../controllers/sms');
const twilioIncomingSmsReq = require('../../mocks/twilioIncomingSmsReq');

describe.only('Sms Controller', () => {
  let messagingResponseMessageStub;
  let conferenceCreateStub;

  beforeEach(() => {
    messagingResponseMessageStub = sinon.stub(twiml.MessagingResponse.prototype, 'message').returns(true);
    conferenceCreateStub = sinon.stub(global.db.Conference, 'create').resolves({ id: 1 });


  afterEach(() => {

  it.only('should call the originator and recipient', () => {
    let requestBody = _.clone(twilioIncomingSmsReq);
    let twilioDialStub = sinon.stub(twilio.calls, 'create').resolves(true);

    return SmsController.incoming(requestBody)
      .then(() => {
        sinon.assert.calledWith(twilioDialStub, {
          to: requestBody.From,
          from: requestBody.To,
          url: `${process.env.API_URL}/calls?id=1`

        sinon.assert.calledWith(twilioDialStub, {
          to: '+number',
          from: requestBody.From,
          url: `${process.env.API_URL}/calls?id=1`



But in my code, the actual twilion.calls.create function is called. Not the stub. What am I doing wrong?

All topic

How to interpret the identity function in this formula?

I am confused by the identity function notation in a formula:

$f(y|theta)= thetacdot e^{-thetacdot y}I_{(0, infty)}(y)$

Could someone help me understand what $I_{(0, infty)}(y)$ means in the formula?

Thank you so much in advance!

All topic

differentiation integral function with respect to the ratio of two variables

I got an integral function as shown in the pictureenter image description here, is it possbile for me to do the partial derivative enter image description here? If so, what is the result? if not, why?

All topic

spark join change equalTo function

I have two datasets and I would like to merge the tables if the element of a column contains the element of the other.
How can I do?

val df = infodf.join(comcapdf, 
    df1.col("Complete Name").equalTo(df2.col("Name")))


val df = infodf.join(comcapdf, 
    df1.col("Complete Name").ifContain(df2.col("Name")))

All topic

Which style is better: Return a DWORD value from function or pass a pointer to DWORD in C++?

I’m designing and implementing a DLL and there is a function I need to get the length of a string that I can do in two ways:

DWORD GetSecondNameLength()

HRESULT GetSecondNameLength(DWORD *length)

Can anyone suggest which style is better? This is not a COM DLL so return type doesn’t have to be HRESULT, it could be a BOOL or some error code. I’m just using HRESULT to illustrate here.

All topic