Main Content

Results for

When I run my matlab code, I got this error
I have guaranteed that my header size (info.raw.sizeof_hdr) is 348
but when I run niftiwrite(V, filepath, info), I also got assertion failed
Error using assert
Assertion failed.
Error in niftiwrite (line 104)
assert(headerBytes == 348||headerBytes == 540);
Error in processing_final (line 110)
niftiwrite(V{1},strcat(Folderpath,Folder(num,1).name,'\RoiVolume\RCA_revised.nii'),info{1});
How can I fix this problem ?
#include <WiFi.h>
#include <Wire.h>
#include <WireSlave.h>
#include "ThingSpeak.h"
const char* ssid = ; // your network SSID (name)
const char* password = ; // your network password
WiFiClient client;
unsigned long myChannelNumber = ; // Channel ID:
const char* myWriteAPIKey = ; // API kluc
#define SDA_PIN 13
#define SCL_PIN 14
#define I2C_SLAVE_ADDR 0x04
int hodnota;
int MenoVahy;
// Timer variables
unsigned long lastTime = 0;
unsigned long timerDelay = 30000;
void receiveEvent(int howMany);
void setup() {
Serial.begin(115200); //Initialize serial
WiFi.mode(WIFI_STA);
ThingSpeak.begin(client); // Initialize ThingSpeak
bool success = WireSlave.begin(SDA_PIN, SCL_PIN, I2C_SLAVE_ADDR);
if (!success) {
Serial.println("I2C slave init failed");
while (1)
delay(30000);
}
WireSlave.onReceive(receiveEvent);
}
void loop()
{
if ((millis() - lastTime) > timerDelay) {
if (WiFi.status() != WL_CONNECTED) {
Serial.print("Pripájam sa k sieti...");
while (WiFi.status() != WL_CONNECTED) {
WiFi.begin(ssid, password);
delay(5000);
}
Serial.println("\nPripojené.");
}
sendDataToThingSpeak();
lastTime = millis();
}
// the slave response time is directly related to how often
// this update() method is called, so avoid using long delays
// inside loop(), and be careful with time-consuming tasks
WireSlave.update();
if (MenoVahy == 2) {
Serial.println(hodnota); // print the integer
}
// let I2C and other ESP32 peripherals interrupts work
delay(1);
}
void receiveEvent(int howMany)
{
while (1 < WireSlave.available()) // loop through all but the last byte
{
MenoVahy = WireSlave.read(); // receive byte as a character
}
hodnota = WireSlave.read(); // receive byte as an integer
}
void sendDataToThingSpeak() {
// Nastavte polia s hodnotami
ThingSpeak.setField(1, 10);
ThingSpeak.setField(2, 20);
ThingSpeak.setField(3, 30);
ThingSpeak.setField(4, 40);
ThingSpeak.setField(5, 50);
ThingSpeak.setField(6, 60);
ThingSpeak.setField(7, 70);
ThingSpeak.setField(8, 80);
int x = ThingSpeak.writeFields(myChannelNumber, myWriteAPIKey);
if (x == 200) {
Serial.println("Úspešne aktualizovaný kanál.");
}
else {
Serial.println("Problém s aktualizáciou kanála. HTTP chybový kód: " + String(x));
}
}
I have carefully followed the instructions to load data into my channel without success.
1 how do I check if I have a wifi connection?
2 the following lines are my thingspeak commands
char thingSpeakAddress[] = "api.thingspeak.com";
unsigned long myChannelNumber = 2202392;
const char * myWriteAPIKey = "xxxxxxxxxxxxxxxx";
String myStatus = "";
ThingSpeak.begin( client );
ThingSpeak.setField(1, volts2);
ThingSpeak.setField(2, adc2);
I can seed the data on arduino serial monitor. I am using an ESO8266 connected to a win 10 PC
Any help will be much appreciated as I have spent a lot of time trying to solve the problem
Joe
Joe
Last activity on 21 Jun 2023

Using mqtt3.thingspeak.com, initially everything works well. but it appears the connection is disconnected after a period of inactivity. Is this expected? Is there a workaround? is some kind of keepalive expected?
Traceback (most recent call last):
File "microdot_asyncio.py", line 368, in dispatch_request
File "microdot_asyncio.py", line 432, in _invoke_handler
File "main.py", line 39, in toggle_led
File "umqtt/simple.py", line 134, in publish
OSError: [Errno 128] ENOTCONN
I have developed an MATLAB application for using as standalone or web based application which also includes trained datasets in it's code. Now i download the package having code, readme file and trained datasets. It takes online data and user input after installing its standalone function but it never shows output which it has to take from trained datasets. Kindly help what is the procedure to upload trained datasets in MATLAB standalone application.
Image Analyst
Image Analyst
Last activity on 19 Aug 2023

half full.
12%
half empty.
4%
both.
12%
twice as big as it needs to be.
15%
1/2 full of beer, 1/2 full of air.
17%
What glass???
39%
6618 votes
Hello all....
I have used MATLAB code to convert .bmp file to hex format. This converted hex file shows zero for all values.
Why such result?What is the posibility?
Please guide...
Wie füge ich einen Zeilenumbruch mit ThingSpeak.setStatus(Text mit Zeilenumbruch)ein?
0D 0A funktioniert nicht.
Hi,
I am using ThingSpeak with Raspberry Pi Pico W, by using python langage.
I am sending some pressure data from the raspberry with this method :
request = urequests.post('http://api.thingspeak.com/update?api_key=' + THINGSPEAK_WRITE_API_KEY, json=dht_readings, headers=HTTP_HEADERS)
And it works pretty good, i have fields with the new data every 15sec.
But now i am trying send a CLEAR request by using the following method :
url = 'http://api.thingspeak.com/channels/{}/fields/{}.json?api_key={}&days={}'.format(CHANNEL_ID, FIELD_NUMBER , THINGSPEAK_WRITE_API_KEY, NUM_DAYS )
clear_request = urequests.delete(url)
Nothing to be done.
I also tried to clean or delete directly all info in the channel and not only the fields' data by this method :
delete_url = 'https://api.thingspeak.com/channels/{}/feeds?api_key={}'.format(CHANNEL_ID,THINGSPEAK_WRITE_API_KEY)
clear_request = urequests.delete(delete_url)
Still not working.
I tired several ways, clearing the channel, deleting the channel, sending some empty update... none of them works.
Clear Channel is working only from the website when clicking on the button, i would like to do it with a request.
So to make a little summary of what i am looking for : I want to automatically send a clear request from my microcontroller to thingspeak channel 1 each X times.
Is there any way to make it possible ?
Thank you for your answer.
Sincerly Arthur
Hi all,
I am so far on a free account.
I have setup 1 channel. I am sending 3 values from a bitShake SmartMeterReader every 20 seconds to this channel.
When trying to send additional data from my solar inverter every 5min! and calculate some data coming from my bitShake (e.g. once per hour) and send it back to the channel I receive the following error:
Requests are too frequent. For further information, see Limitations in the documentation.
Now I understand that my messages (write orperations) to my channel are limited to 3 Mio / year or 8200/day. With my current setup I am at little more than 4K messages per day and since I just recently started my account I have still 2.840.531 messages left.
How come I get that error even if I switch even if my message limit is far from reached?
Thanks in advance for your time! Much appreciated!
btw. The link "Limitations" where it is supposed to be explained is not working (for me)
Hello!
Im trying to split my Data into 6 different values but the system wont work
I thought this should work, but im not sure how my data is being sent as,
its being sent as a a table, but thats about it. Anyone have any idea what ive done wrong?
I've noticed a few times that a bulk update can take a while to appear. Normally a few minutes at most but at the moment it seems to be much longer, hours maybe. I know the message I sent had been received as I get an RC = 202 as normal. I sent a non bulk update via the browser and it appeared imediately.
Is this something I have to get used to ? It's a problem when I first set up a device and look at Thingspeak to check it's sending messages correctly (I send a bulk update with 1 message when it first connets). Even a single data point sent in batch form is not appearing.
Update: the data has started appearing but it's still hours behind.
figure out what my old code does
18%
write code comments for future me
11%
address a code analyzer warning
3%
reflect on the skills I've gained
8%
get food on my mouse and keyboard
38%
All of the above
22%
16434 votes
Getting Started with Simulink | Tips and Tricks to Get the Most Out of Simulink
Watch live as Tianyi Zhu and Ashwin Dhawad walk through how you can get started with Simulink by modeling, simulating, and tuning a PID controller for a DC Motor. This session isn’t just for beginners; they will show you the latest and greatest tips and tricks to help you get the most out of Simulink.
Date & Time: May 25, 2023 at 11:00 am EDT (see time in your time zone)
MATLAB Central has been great community-based MATLAB resources, but you can now access its content programmatically via the public API, and I created a MATLAB function to take advantage of that. You can learn more here https://api.mathworks.com/community
Example:
data = searchMATLABCentral("plotting",scope="matlab-answers",sort_order="created desc",created_after=datetime("2023-01-01"));
T = struct2table(data.items);
T(:,["created_date","title","is_answered"])
Output
Function
function results = searchMATLABCentral(query,options)
% SEARCGMATLABCENTRAL retrieves content of the MATLAB Central for a given
% query and returns the result as a struct.
% The function uses MathWorks RESTful API to search for content.
% The API is rate limited via IP throttling. No authentication is required.
% See API documentation for more details https://api.mathworks.com/community
%
% Input Arguments:
%
% query (string) - Required. The search query string.
% scope (string) - Optional. Specify the artifact. If not specified,
% the scope defaults to 'matlab-answers'.
% Other options include 'file-exchange','blogs','cody',
% 'community-highlights', and 'community-contests'.
% tags (string) - Optional. Specify a comma-separated list of tags.
% created_before (datetime) - Optional. Specify the last date in the results
% created_after (datetime) - Optional. Specify the first date in the results
% sort_order (string) - Optional. Speficy the order of the results.
% If not specified, it defaults to "relevance desc".
% Other options include 'created asc', 'created desc',
% 'updated asc','updated desc', 'relevance asc',
% and 'relevance desc'.
% page (integer) - Optional. Specify the page to retrieve.
% If the 'has_more' field in the result is positive,
% increment this argument to retrieve the next page.
% count (integer) - Optional. Specify the number of results as a value
% between 1 and 50; The default is 10.
%
% Output Arguments:
%
% results (struct) - Structure array containing the results of the search.
% validate input arguments
arguments
query string {mustBeNonzeroLengthText,mustBeTextScalar}
options.scope string {mustBeMember(options.scope,["matlab-answers", ...
"file-exchange","blogs","cody","community-highlights", ...
"community-contests"])} = "matlab-answers";
options.tags string {mustBeNonzeroLengthText,mustBeVector}
options.created_before (1,1) datetime
options.created_after (1,1) datetime
options.sort_order string {mustBeMember(options.sort_order,["created asc", ...
"created desc","updated asc","updated desc","relevance asc","relevance desc"])}
options.page double {mustBeInteger,mustBeGreaterThan(options.page,0)}
options.count double {mustBeInteger,mustBeInRange(options.count,1,50)}
end
% API URL and endpoint
url = "https://api.mathworks.com/community";
endpoint = "/v1/search";
% convert MATLAB datetime to the internet datetime format string
if isfield(options,"created_before")
options.created_before = string(options.created_before,"yyyy-MM-dd'T'HH:mm:ss'Z'");
end
if isfield(options,"created_after")
options.created_after = string(options.created_after,"yyyy-MM-dd'T'HH:mm:ss'Z'");
end
% convert optional inputs into a cell array of key-value pairs
keys = fieldnames(options);
vals = struct2cell(options);
params = [keys,vals].';
% call the API
try
results = webread(url+endpoint,"query",query,params{:});
catch ME
rethrow(ME)
end
end
I can't get my dynamic position data to display.My JASON body looks like this:
{ "api_key": "XXXXXXXXXXXXXXX", "created_at": "2023-05-15T23:17:54.000Z", "field1": 50.71875, "field2": 20.375, "field3": 4.1132812, "field4": 91.625, "field5": 1523985, "lat": -25.8152875, "long": 152.58867187500002, "status": "Bauple" }
Fields 1-4 display fine, as does the Status field. However the position map always shows a balloon at (0,0). I've tried "lat" and "latitude", "long" and "longitude", but no luck. Any ideas?
This is weird to me.
I am connected through a SIM7060 module to mqtt3.thingspeak.com on port 1883
I have an IP address., I am connected to the MQTT server.
I see the number of entries increasing in my channel. However, no data visible in the graph.
This is the AT command to the SIM7080 module : AT+SMPUB="channels/**********/publish",37,1,1
And then I send the payload : field1=1&field2=2&field3=3&field4=400
As said, each time a send a request I see the number of entries increasing, but no real data.
The export shows me this :
created_at,entry_id,field1,field2,field3,field4
2023-05-15 17:33:40 UTC,1,,,,
2023-05-15 17:34:59 UTC,2,,,,
2023-05-15 17:36:16 UTC,3,,,,
2023-05-15 17:37:31 UTC,4,,,,
2023-05-15 17:38:48 UTC,5,,,,
Any idea why the content of the field is empty?
Thanks
I have a channel where I upload measurements from a BME280 sensor, but on the Pi Pico I calculate the min/avg/max temperature every 10 minutes.
I never have created a visualisation from scratch before. Usually, I can continue from a working example, but I know nothing (yet) about the mathlab language...
Can someone show me how to create a diagram of my temperatures, were the average temp is a (thick) solid line, and the min/max temperatures are a filled out area above and below?
Is it possible to change the color (Background and the Meter itself) of the Gauge Widget ?
The Widget Edit Menu will only offers Colors for the range Indicators, but not for the Gauge itself.
The background in black would be ideal.